0

I am designing a rest api in which I need to add tags to an entity. The entity is created using POST /content where the json data is passed in the request body. I want to allow adding tags while the POST request is being made, and also later on. This is what I have.

POST /content?tag=foo&tag=bar

PUT  /content/{id}?tag=baz&tag=bat

Now, how do I allow deleting tags? What would be a better approach>

4

1 回答 1

3

简短的回答:你会这样做吗

假设您的实体是您创建实体的内容,您将:

POST /entity

这将创建一个实体并返回一个实体 ID,例如 29292

如果您需要在实体上添加标签,您可以像这样沿着层次结构向下移动:

POST /entity/29292/tags

要删除标签,您只需

DELETE /entity/29292/tags

长答案:您想学习本指南以创建具有更多详细信息和最佳实践的 restful api。

于 2013-02-11T23:07:51.893 回答