I’ve encountered API that tell as being “restful” but then I see resources with verbs instead of reserving those said verbs to the METHOD
. Here’s some (paths shortened so only the relevant method and path parts are shown):
POST /things/84/lock
POST /things/84/unlock
POST /things/84/edit
POST /things/prepend
(Adding to the beginning of the ordered collection)
Why doesn’t it make sense to do instead:
LOCK /things/84
UNLOCK /things/84
PATCH /things/84
orEDIT /things/84
(I prefer the first one)PREFIX /things/prepend
orPREPEND /things/prepend
I’ve only been told again and again that this is not restful because it must only use GET, POST, PUT, DELETE and PATCH to remain restful.
What logical explanation exists for having verbs in the path section of the URL for restful API?
Notes:
- I can’t show you real life examples so I won’t be pointing fingers at anybody.
- As for proxy limitations excuse I’ve been experiencing. It was valid while no workaround existed. Nowadays, most modern frameworks have mechanisms to allow method override using query variables or headers (with de-facto standards, even).