我正在尝试在 .NET Core 3.0 Preview 9 web api 上实现 JsonPatch。
该模型:
public class TestPatch
{
public string TestPath { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
Web API 端点:
[HttpPatch()]
public async Task<IActionResult> Update([FromBody] JsonPatchDocument<TestPatch> patch)
{
...........
return Ok();
}
Run Code Online (Sandbox Code Playgroud)
JSON 有效负载:
[
{
"op" : "replace",
"path" : "/testPath",
"value" : "new value"
}
]
Run Code Online (Sandbox Code Playgroud)
通过 Postman 使用 PATCH,我收到此错误:
{
"type": "https://tools.ietf.org/html/rfc7231#section-6.5.1",
"title": "One or more validation errors occurred.",
"status": 400,
"traceId": "|492c592-4f7de4d16a32b942.",
"errors": {
"$": [
"The JSON value could …Run Code Online (Sandbox Code Playgroud)