-1

大家好,我们正在使用 php curl 向 orocommerce 发送补丁请求:

网址:网址http://oro.demo/commerce/public/admin/api/products/71

数据为:

{"data":{"type":"products","id":"70","attributes":{"sku":"10305","status":"enabled","variantFields":[], "productType":"simple","featured":true,"newArrival":false},"relationships":{"attributeFamily":{"data":{"type":"attributefamilies","id":"1 "}},"inventory_status":{"data":{"type":"prodinventorystatuses","id":"in_stock"}},"names":{"data":[{"type":"localizedfallbackvalues" ,"id":"names-1"}]},"primaryUnitPrecision":{"data":{"type":"productunitprecisions","id":"product-unit-precision-id-3"}}}},"included":[{"type":"productunitprecisions","id":"product-unit-precision-id-3","attributes":{ "precision":"7","conversionRate":"5","sell":"0"},"relationships":{"unit":{"data":{"type":"productunits","id ":"set"}}}},{"type":"localizedfallbackvalues","id":"names-1","attributes":{"fallback":null,"string":"Fruit Oatmeal"," text":null},"relationships":{"localization":{"data":null}}}]}product-unit-precision-id-3","attributes":{"precision":"7","conversionRate":"5","sell":"0"},"relationships":{"unit": {"data":{"type":"productunits","id":"set"}}}},{"type":"localizedfallbackvalues","id":"names-1","attributes":{ "fallback":null,"string":"Fruit Oatmeal","text":null},"relationships":{"localization":{"data":null}}}]}product-unit-precision-id-3","attributes":{"precision":"7","conversionRate":"5","sell":"0"},"relationships":{"unit": {"data":{"type":"productunits","id":"set"}}}},{"type":"localizedfallbackvalues","id":"names-1","attributes":{ "fallback":null,"string":"Fruit Oatmeal","text":null},"relationships":{"localization":{"data":null}}}]}"id":"set"}}}},{"type":"localizedfallbackvalues","id":"names-1","attributes":{"fallback":null,"string":"Fruit Oatmeal" ,"text":null},"relationships":{"localization":{"data":null}}}]}"id":"set"}}}},{"type":"localizedfallbackvalues","id":"names-1","attributes":{"fallback":null,"string":"Fruit Oatmeal" ,"text":null},"relationships":{"localization":{"data":null}}}]}

作为响应,我们得到了结果错误。

[{"title":"extra fields constraint","detail":"此表单不应包含额外字段:"{"data":{"type":"products","id":"70","attributes ":{"sku":"10305","status":"enabled","variantFields":"."}]

相同的数据在沙盒和邮递员中工作,如附件所示 在此处输入图像描述

4

1 回答 1

1

通过添加 Content-Type: application/vnd.api+json 解决了我的问题。

谢谢你们

于 2020-12-09T06:59:14.210 回答