An application uses HTTP 200 responses for successful deletes. Which HTTP status code is more semantically correct when a DELETE request successfully removes a resource and there is nothing to return?
- A.200 OK with an empty body
- B.410 Gone
- C.202 Accepted
- D.204 No Content
Why D is correct
204 No Content is the appropriate response when a request was successful but there is no body to return. It is the conventional response for successful DELETE operations. 200 OK works but implies a response body. 202 Accepted means the request was received but not yet processed. 410 Gone is for resources that existed but were permanently deleted and should no longer be requested.
Know someone studying for Web App Fundamentals? Send them this one.