Reputation: 134
I have a curious question regarding REST API design!
There is a resource called users
and there are different user-types
Say if I want to delete a user by Rest design I would have an endpoint like
DELETE /users/id
But now I want to delete all users with a specific user-type and maybe other params that I can't send as a query params. I read a bunch of documentation against using body params for DELETE
So I thought having a POST /users/delete
route would be a better option.
Now I am confused if my new route POST /users/delete
can be used for both individual user deletion and multiple user deletion. Does this violate any REST standard?
If not what would be another way to do this?
Upvotes: 0
Views: 456
Reputation: 57279
Does this violate any REST standard?
No - it may violate some of the Rails conventions, but it is perfectly fine as far as a REST client is concerned.
It may help to translate your question into the language of HTML and the world wide web: is there any violation of REST principles if you have two different web forms that submit requests to the same resource?
And the answer is no - it still "just works"; browsers use the standardized processing rules to take the information of the form and from it create the appropriate HTTP request, and then send it across the network to the right place, without needing to know anything about the semantics (aside from the general purpose semantics defined by the HTTP specification).
Upvotes: 1
Reputation: 3126
I believe you can do that. Deleting a single resource can be done using the REST way & deleting multiple can be done using POST /users/delete
There is no "official" standard for RESTful web APIs. This is because REST is an architectural style, while SOAP is a protocol. REST is not a standard in itself, but RESTful implementations make use of standards, such as HTTP, URI, JSON, and XML.
-- Wikipedia
So yeah, you're not violating any REST principles by implementing multi-destroy through POST
Upvotes: 1