簡體   English   中英

帶有“無法取消設置字符串偏移量”的 Shopware 產品 API 響應

[英]Shopware Product API response with "Cannot unset string offsets"

在使用 Shopware 6 的產品 API 進行一些測試后,我收到 500 錯誤,顯示“無法取消設置偏移量字符串”。
這些信息對我來說還不夠,要調試它,因為我對 Shopware 6 API 有點陌生。
這是錯誤:

{
    "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 字段應該是一個對象數組,例如
    "price":[{
        "currencyId":"b7d2554b-0ce8-47cd-82f3-ac9bd1c0dfca",
        "net":"0",
        "gross":"0"
    }],
  1. 您需要從所有 id 字段中刪除破折號,例如 fd1be1ea-884a-4049-b143-605d8dfaa589 => fd1be1ea884a4049b143605d8dfaa589

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM