After some testing with the Product API of Shopware 6 I get a 500 error that says "Cannot unset string of offsets".
That information isnt enought for me, to debug it, sicne iam kinda new to Shopware 6 APIs.
This is the error:
{
"errors": [{
"code": "0",
"status": "500",
"title": "Internal Server Error",
"detail": "Cannot unset string offsets"
}]
}
Iam using this site: https://reqbin.com/
And I call the URL: https://www.my-url.de/api/product via POST Request.
As authorization i use a bearer token i grab from the getToken GET-Request.
My Request-Content looks like the following:
{
"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"
}
I copy paste the taxId and currencyId from a existing database and just format it the same as the productId and parentId i generate manually.
CodePudding user response:
I think you have 2 problems:
- price fields should be an array of objects e.g.
"price":[{
"currencyId":"b7d2554b-0ce8-47cd-82f3-ac9bd1c0dfca",
"net":"0",
"gross":"0"
}],
- You need to remove dashes from all id fields e.g. fd1be1ea-884a-4049-b143-605d8dfaa589 => fd1be1ea884a4049b143605d8dfaa589