如何使用HATEOAS从对象的集合中删除资源?
PUT将设置集合。 PATCH将允许部分更新/添加。
但我该如何进行部分更新/删除?
我是否真的需要将整个uri-list减去1才能删除单个项目?
以此对象为例:
{
"name": "Bob Test",
"description": "this is the descript",
"_links": {
"self": {
"href": "http://localhost/example/1"
},
"example": {
"href": "http://localhost/example/1"
},
"citations": {
"href": "http://localhost/example/1/citations"
},
}
}
该对象有很多引用(集合):
{
"_embedded": {
"citations": [
{
"content": "asdfasdf",
"anchor": null,
"_links": {
"self": {
"href": "http://localhost/citations/1"
},
"citation": {
"href": "http://localhost/citations/1"
},
"bioMarker": {
"href": "http://localhost/citations/1/example"
}
}
},
{
"content": "c2",
"anchor": "prf",
"_links": {
"self": {
"href": "http://localhost/citations/2"
},
"citation": {
"href": "http://localhost/citations/2"
},
"bioMarker": {
"href": "http://localhost/citations/2/example"
}
}
}
]
},
"_links": {
"self": {
"href": "http://localhost/example/1/citations"
}
}
}
现在假设我要删除http://localhost/citations/2
,如何从http://localhost/example/1/citations
集合中移除此特定项?
答案 0 :(得分:0)
从响应中获取内容类型,并将其发送到请求标头“ Accept”中。通常是“ application / xxxxx + json”