An error when sending PATCH with Postman to Asp.net Core webapi(使用 Postman 向 Asp.net Core webapi 发送 PATCH 时出错)
问题描述
我有一个模特,
还有一个存储库,
已在Startup.cs
中注册如下.
其他相关的nuget包已经安装如下.
Additional relevant nuget packages are already installed as follows.
下面给出了一个测试控制器.
A testing controller is given as follows.
使用 Postman,我成功创建了一个新订单,方法是先向服务器发送 POST 动词,然后通过发送 GET 动词确认结果,如下所示.
Using Postman, I successfully created a new order by sending POST verb to the server first and then confirming the result by sending GET verb as follows.
我尝试使用以下内容部分更新订单,但失败了.
I attempted to partially update the order with the following but failed.
错误信息是
JSON 补丁文档格式错误,无法解析.
The JSON patch document was malformed and could not be parsed.
出了什么问题以及如何解决?
What is wrong and how to fix it?
代替
我也试过了
两者都没有帮助.
推荐答案
根据docs 对于 json 补丁,您需要传递一个操作数组而不是单个对象,就像这样
According to the docs for json patch you need to pass an array of operations instead of single object, like so
这篇关于使用 Postman 向 Asp.net Core webapi 发送 PATCH 时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!