Shopware 产品 API 响应 "Cannot unset string offsets"

Shopware Product API response with "Cannot unset string offsets"

在使用 Shopware 6 的产品 API 进行一些测试后,我收到 500 错误,提示“无法取消设置偏移量字符串”。
这些信息对我来说还不够,无法调试它,因为我对 Shopware 6 有点陌生 APIs。
这是错误:

{
    "errors": [{
        "code": "0",
        "status": "500",
        "title": "Internal Server Error",
        "detail": "Cannot unset string offsets"
    }]
}

我正在使用这个网站:https://reqbin.com/
我通过 POST 请求调用 URL: https://www.my-url.de/api/product
作为授权,我使用从 getToken GET-Request 中获取的不记名令牌。
我的请求内容如下所示:

{
    "productId":"fd1be1ea-884a-4049-b143-605d8dfaa589",
    "parentId":"fd1be1ea-884a-4049-b143-605d8dfaa589",
    "name":"Sorelie",
    "taxId":"f68a9c3c-8686-4c2e-a759-7062fc457cf7",
    "productNumber":"16345583549",
    "minPurchase":"1",
    "purchasePrice":"0",
    "price":{
        "currencyId":"b7d2554b-0ce8-47cd-82f3-ac9bd1c0dfca",
        "net":"0",
        "gross":"0"
    },
    "stock":"0",
    "images":"",
    "atributes":"",
    "categoryId":"29"
}

我从现有数据库复制粘贴 taxId 和 currencyId,并将其格式化为与我手动生成的 productId 和 parentId 相同的格式。

我认为你有两个问题:

  1. 价格字段应该是一个对象数组,例如
    "price":[{
        "currencyId":"b7d2554b-0ce8-47cd-82f3-ac9bd1c0dfca",
        "net":"0",
        "gross":"0"
    }],
  1. 您需要从所有 ID 字段中删除破折号,例如 fd1be1ea-884a-4049-b143-605d8dfaa589 => fd1be1ea884a4049b143605d8dfaa589