REST - delete a collection of objects

Is this possible? Did people who designed REST just think that they would delete things one at a time forever?

So let's say I have 10 Foo ID 1-10

I want to remove IDs 3, 6 and 9 with a single HTTP DELETE call.

Can I do this without offending the Pope?

+6
rest web-services
source share
4 answers

If you are concerned about insulting the pope, you might want to spend some time reading the scriptures :-) http://tools.ietf.org/html/draft-gregorio-uritemplate-04

I think all your questions will be answered.

-one
source share

Most of the APIs that I'm familiar with do not allow you to delete multiple objects at the same time, but to perform other operations with several objects with URL parameters, such as ?id=3,6,9 or ? id=3&id=6&id=9 ? id=3&id=6&id=9 . Therefore, it would be quite common to do one of the following:

 DELETE /foos?id=3,6,9 

or

 DELETE /foos?id=3&id=6&id=9 
+5
source share

You can also DELETE /Foos?id=3,6,9 .

+3
source share

I do not think this is a problem.

DELETE http://www.example.com/foos means deleting all.

DELETE http://www.example.com/foos {3,6,9} means deleting foo 3, 6, 9.

0
source share

All Articles