0

I am in a middle of a discussion here. Imagine that you have I want to delete all records from a collection using REST to https://api.example.com/files.

Is DELETE https://api.example.com/files a valid call?

Renato Shumi
  • 198
  • 1
  • 1
  • 14

2 Answers2

0

You can refer published guidance regarding REST.

https://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html

It appears to be a valid scenario.

Similar discussion here: Is an entity body allowed for an HTTP DELETE request?

AKV
  • 46
  • 4
  • By one of the designers of HTTP: [RFC 2616 is dead](https://www.mnot.net/blog/2014/06/07/rfc2616_is_dead). Please use [RFC 7230](https://tools.ietf.org/html/rfc7230) - 7235 from now on. RFC 7231 in regards to a payload on a DELETE operation states the following: `A payload within a DELETE request message has no defined semantics; sending a payload body on a DELETE request might cause some existing implementations to reject the request.` – Roman Vottner May 14 '20 at 09:14
0

Is DELETE https://api.example.com/files a valid call?

Semantically, DELETE /files is no different from DELETE /anythingElse; that's the promise of the uniform interface, that all resources understand the methods to mean the same thing.

In the case of DELETE, the semantics are currently defined by RFC 7231.

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 your server happens to delete a bunch of rows in its data store when handling this request? That's just a side effect - it's an implementation detail of no concern to anyone other than the server itself.

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.

Relatively few resources allow the DELETE method -- its primary use is for remote authoring environments, where the user has some direction regarding its effect.

Community
  • 1
  • 1
VoiceOfUnreason
  • 52,766
  • 5
  • 49
  • 91