开发者

REST - Deleting a collection of objects

开发者 https://www.devze.com 2023-02-09 10:23 出处:网络
Is such a thing possible? Did the people who designed REST just think they would de开发者_开发百科lete things one at a time forever?

Is such a thing possible? Did the people who designed REST just think they would de开发者_开发百科lete 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?


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


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


I don't think it's a problem.

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

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


If you are concerned about offending the pope, maybe you should spend some time reading the scriptures :-) https://datatracker.ietf.org/doc/html/draft-gregorio-uritemplate-04

I think all your questions will be answered in there.

0

精彩评论

暂无评论...
验证码 换一张
取 消