【发布时间】:2019-04-18 09:51:02
【问题描述】:
我正在使用来自 github repo {json:api} 的 json:api 规范测试 dotnet 核心的样板库。当我从邮递员发送时,GET(有或没有查询)、POST 和 DELETE 的端点按预期工作。但是我找不到使用 PUT 或 PATCH 更改现有资源的工作示例。当我发送带有数据的补丁请求时,它给我回复“200 OK”但它在数据库中没有改变。以下是我的要求和回应。
Request GET : http://localhost:5000/api/people -> 200 OK Response : [ { "name": "Samuel", "articles": null, "id": 2, "stringId": "2" }, { "name": "John", "articles": null, "id": 3, "stringId": "3" }, { "name": "Robbin", "articles": null, "id": 4, "stringId": "4" } ] Request GET: http://localhost:5000/api/people/2 -> 200 OK Response : { "name": "Samuel", "articles": null, "id": 2, "stringId": "2" } Request GET: http://localhost:5000/api/people/2?include=articles -> 200 OK Response : { "name": "Samuel", "articles": [], "id": 2, "stringId": "2" } Request POST: http://localhost:5000/api/people -> 201 Created Request Body: {"name":"Samuel"} Response : { "name": "Samuel", "articles": null, "id": 2, "stringId": "2" } Request DELETE: http://localhost:5000/api/people/2 -> 204 No Content
如何更新数据?
【问题讨论】: