In REST, when trying to delete a resource that has already been deleted , which code should I return?

PS: I generally fluctuate between 404 and 410

  • You can probably determine the codes for errors yourself and not suffer. Now take something as a basis from vk for example vk.com/dev/errors .... - Alexey Shimansky
  • @ Alexey Shimansky I am interested in REST conventions. For lack of such conventions RoR - Viktor

1 answer 1

In general, the essence of REST in idempotency. See the specification . According to the idea it does not matter whether the earlier has been removed already or not.

From RESTful Web Services Cookbook: Solutions for Improving Scalability and Simplicity :

The DELETE method is idempotent. This is a request for the server. But in practice, the implementation of the deleted resources. Otherwise, it can return a 404 (Not Found).

So, it is recommended to return the code 200. But, in some cases it is possible to return 404.