Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

REST - Deleting a collection of objects

Is such a thing possible? Did the people who designed REST just think they would delete things one at a time forever?

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

I want to delete ID's 3, 6, and 9 with a single HTTP DELETE call.

Is there any I can do this without offending the Pope?

like image 680
M. Ryan Avatar asked Feb 10 '11 06:02

M. Ryan


People also ask

How do I delete data from REST API?

Use the sObject Rows resource to delete records. Specify the record ID and use the DELETE method of the resource to delete a record.

Can delete REST API have a body?

We don't support the Request body with the DELETE method. It does allow you to pass HTTP Query Parameters.


1 Answers

Most APIs I'm familiar with don't allow deleting of multiple entities at a time but to perform other operations on multiple entities with URL parameters like ?id=3,6,9 or ? id=3&id=6&id=9. So it would be fairly common to do either of the following:

DELETE /foos?id=3,6,9

or

DELETE /foos?id=3&id=6&id=9
like image 171
abraham Avatar answered Sep 28 '22 14:09

abraham