【发布时间】:2016-05-19 07:43:10
【问题描述】:
我正在创建一个 API,我需要创建一个定义为的帖子:
{
"Title": "Blog first post",
"Body": "Some body text for the post",
"PublishedAt": "2016-02-08",
"Category": {
"Id": "20",
"Name": "Travel"
},
"Tags": [
{ "Id": "12", "Name": "Vacation" },
{ "Id": "18", "Name": "Beach" }
]
}
您会向 API 发布什么内容?以下?
{
"Title": "Blog first post",
"Body": "Some body text for the post",
"PublishedAt": "2016-02-08",
"Category": {
"Id": "20",
},
"Tags": [
{ "Id": "12" },
{ "Id": "18" }
]
}
或者您会按照以下步骤进行:
POST /category/20/posts
POST /posts/recently-created-post-id/tags >> Add tags one by one?
但是当整个数据都准备好发布时该怎么办?
REST API 中这种情况的标准是什么?
【问题讨论】:
标签: angularjs api rest asp.net-web-api