I have a resources with uri /api/books/122
, if this resource doesn't exist at the point where a client sends HTTP Delete for this resource, what is the appropriate response code from this action? Is it 404 Not Found?
Thanks
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Yes, it would be 404.
In general it will be a 400 series error if the request is wrong somehow, and a 500 series error if something goes awry on the server.
回答2:
The response code for a delete call can be any of the following :
DELETE /api/book/122
- The server successfully processed the request, but is not returning any content204 No Content
DELETE /api/book/122
- Resource does not exist404 Not Found
DELETE /api/book/122
- Resource already deleted410 Gone
DELETE /api/book/122
- Users does not have permission403 Forbidden
DELETE /api/book/122
- Method Not Allowed405 Method Not Allowed
DELETE /api/book/122
- Conflict (User can resolve the conflict and delete)409 Conflict
In your case 404 is apt.