我有端点PATCH /联系人 我想用标签列表来修补我的联系人,因此为此创建了一个属性,但我不知道API调用主体必须是什么。 我认为{“ tags”:[“ tag1”,“ tag2”]}但我不知道如何通过REST删除或更新列表条目
答案 0 :(得分:0)
我建议使用JSON Patch RFC 6902作为指导。基本上,您将发送一个JSON文档,其中包含有关如何修改端点的说明。样本可能类似于:
PATCH /my/data HTTP/1.1
Host: example.org
Content-Length: 326
Content-Type: application/json-patch+json
If-Match: "abc123"
[
{ "op": "test", "path": "/a/b/c", "value": "foo" },
{ "op": "remove", "path": "/a/b/c" },
{ "op": "add", "path": "/a/b/c", "value": [ "foo", "bar" ] },
{ "op": "replace", "path": "/a/b/c", "value": 42 },
{ "op": "move", "from": "/a/b/c", "path": "/a/b/d" },
{ "op": "copy", "from": "/a/b/d", "path": "/a/b/e" }
]