Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Lee Davis:
Is a HTTP DELETE request idempotent?
Nov 01, 2013 @ 14:15:18

Lee Davis has a new post to his site with some thoughts about RESTful APIS and the correct response to DELETE calls when a resource has already been removed. One camp says a 404 should be thrown as it's no longer there, the other says 204 a "No Content" should always be returned. Lee looks at both sides of the argument and shares some of his own thoughts too.

Recently I had a read of an interesting post by Lukas Smith (@lsmith) about the use of the DELETE method when building RESTful services. I wanted to get my thoughts down on this. Mostly to help myself, but if it helps you determine a better approach, then great. I’m nowhere near qualified enough to preach, so this is by no means a “you should do it this way / my way is correct post”, just food for thought. Besides, there are probably more questions here than answers.

He talks about the idea of "idempotence" when it comes to REST APIs and how it relates back to the DELETE discussion. He points out that the term has more to do with the end result of the request and not so much about how it's handled (and any "side effects" that may come with it). Various checks on the resource in question - like "does it exist" - could be considered a side effect of its operation. In his opinion, though, the 200 series of responses are more appropriate when a resource is actually deleted.

tagged: delete rest api idempotent opinion resource

Link: http://www.duckheads.co.uk/is-a-http-delete-requests-idempotent/491


Trending Topics: