开发者

REST - Deleting a collection of objects

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜