1

I wonder about the REST API structure: Is it correct to use the HTTP DELETE method without effectively deleting a resource on the webserver dir but in a database?

4
  • then why do you want to use DELETE? Commented Sep 13, 2017 at 7:54
  • 1
    REST handles resources. If you make a DELETE operation, there should be at least one less resource to get over the REST interface after. Where or how this resource is persistent is none of REST's concerns Commented Sep 13, 2017 at 7:54
  • define deleting a resource on the webserver However you might want to use soft deletes that way the record still exists, it is just marked as deleted using a column deleted Commented Sep 13, 2017 at 7:55
  • Possible duplicate of RESTful Soft Delete Commented Sep 13, 2017 at 10:09

1 Answer 1

3

The RFC 7231 defines the semantics of the HTTP DELETE method.

It expresses a deletion operation on the URI mapping (and it doesn't expect that the associated content will be actually deleted from the server). Whether the actual content will be deleted or not or whether it can be restored or not, is up to the server implementation.

See the quote below (highlights are mine):

4.3.5. DELETE

The DELETE method requests that the origin server remove the association between the target resource and its current functionality. In effect, this method is similar to the rm command in UNIX: it expresses a deletion operation on the URI mapping of the origin server rather than an expectation that the previously associated information be deleted.

If the target resource has one or more current representations, they might or might not be destroyed by the origin server, and the associated storage might or might not be reclaimed, depending entirely on the nature of the resource and its implementation by the origin server (which are beyond the scope of this specification). Likewise, other implementation aspects of a resource might need to be deactivated or archived as a result of a DELETE, such as database or gateway connections. In general, it is assumed that the origin server will only allow DELETE on resources for which it has a prescribed mechanism for accomplishing the deletion. [...]

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.