Hallo liebe Shopware Community,
leider hab ich in Python ein Problem mit dem posten vom body an die Shopware API:
folgenden Fehler erhalte ich
{
"errors":[
{
"status":"500",
"code":"FRAMEWORK__WRITE_TYPE_INTEND_ERROR",
"title":"Internal Server Error",
"detail":"Expected command for \"Shopware\\Core\\Content\\Product\\ProductDefinition\" to be \"Shopware\\Core\\Framework\\DataAbstractionLayer\\Write\\Command\\InsertCommand\". (Got: Shopware\\Core\\Framework\\DataAbstractionLayer\\Write\\Command\\UpdateCommand)",
"meta":{
"parameters":{
"definition":"Shopware\\Core\\Content\\Product\\ProductDefinition",
"expectedClass":"Shopware\\Core\\Framework\\DataAbstractionLayer\\Write\\Command\\InsertCommand",
"actualClass":"Shopware\\Core\\Framework\\DataAbstractionLayer\\Write\\Command\\UpdateCommand"
}
}
}
]
}
Leider konnte ich zu diesem Fehler direkt nichts finden, helft mir bitte ggf. auch beim Googlen wenn ich zu bled dafür bin
Code den ich verwende ist folgender:
def transferartikels():
print("Artikeltransfer wurde gestartet")
url = "https://tollewebseite.shop/api/product"
headers = CaseInsensitiveDict()
bearertoken()
headers["Authorization"] = "Bearer " + authkey
headers["Content-type"] = "application/json"
datas = open("art-import.json", "r").read()
print("Jsondatei geladen")
resp = requests.post(url, headers=headers, data=datas)
print(resp.json())
print("Aritkeltranfer wurde beendet")
print("[-------------------------------------------]")
transferartikels()
JSON Datei die Importiert wird:
{
"id":"af204985dc6c42e094dca007ccae2070",
"stock":0,
"productNumber":"{artnumb}",
"name":"{artname}",
"taxId":"9d4a11eeaf3a41bea44fdfb599d57058",
"manufacturerId":"e31fe228f4b042c1ac2ef61143aa5fb3",
"price":[
{
"currencyId":"b7d2554b0ce847cd82f3ac9bd1c0dfca",
"net":100,
"gross":119,
"linked":true
}
],
"children":[
{
"productNumber":"{artnumb}-99",
"stock":0,
"options":[
{
"id":"31814c89f6e94b2d99986ad1363dce78"
}
]
},
{
"productNumber":"{artnumb}-22",
"stock":0,
"price":[
{
"currencyId":"b7d2554b0ce847cd82f3ac9bd1c0dfca",
"net":100,
"gross":119,
"linked":true
}
],
"options":[
{
"id":"fd08f8b6596746129d3fef75eb366389"
}
]
},
{
"productNumber":"{artnumb}-85",
"stock":0,
"price":[
{
"currencyId":"b7d2554b0ce847cd82f3ac9bd1c0dfca",
"net":100,
"gross":119,
"linked":true
}
],
"options":[
{
"id":"73567c14a5724e5ca253385d56ee9c88"
}
]
},
{
"productNumber":"{artnumb}-48",
"stock":0,
"price":[
{
"currencyId":"b7d2554b0ce847cd82f3ac9bd1c0dfca",
"net":100,
"gross":119,
"linked":true
}
],
"options":[
{
"id":"cc478939f5f64f2dbfe6d33ae0895b23"
}
]
},
{
"productNumber":"{artnumb}-80",
"stock":0,
"price":[
{
"currencyId":"b7d2554b0ce847cd82f3ac9bd1c0dfca",
"net":100,
"gross":119,
"linked":true
}
],
"options":[
{
"id":"6da09445b5ef419a8e5b98d0ae3da17b"
}
]
},
{
"productNumber":"{artnumb}-68",
"stock":0,
"price":[
{
"currencyId":"b7d2554b0ce847cd82f3ac9bd1c0dfca",
"net":100,
"gross":119,
"linked":true
}
],
"options":[
{
"id":"f63285d3f23f441c993a2f2aab499082"
}
]
},
{
"productNumber":"{artnumb}-50",
"stock":0,
"price":[
{
"currencyId":"b7d2554b0ce847cd82f3ac9bd1c0dfca",
"net":100,
"gross":119,
"linked":true
}
],
"options":[
{
"id":"5503ef20a7424bc58facdac2b8ca6ac5"
}
]
},
{
"productNumber":"{artnumb}-77",
"stock":0,
"price":[
{
"currencyId":"b7d2554b0ce847cd82f3ac9bd1c0dfca",
"net":100,
"gross":119,
"linked":true
}
],
"options":[
{
"id":"24da21ac840d4abbb358d01bb03ad74c"
}
]
},
{
"productNumber":"{artnumb}-91",
"stock":0,
"price":[
{
"currencyId":"b7d2554b0ce847cd82f3ac9bd1c0dfca",
"net":100,
"gross":119,
"linked":true
}
],
"options":[
{
"id":"a300f872a68f4f93b1af3d6e1c50e397"
}
]
}
],
"configuratorSettings":[
{
"optionId":"31814c89f6e94b2d99986ad1363dce78"
},
{
"optionId":"fd08f8b6596746129d3fef75eb366389"
},
{
"optionId":"73567c14a5724e5ca253385d56ee9c88"
},
{
"optionId":"cc478939f5f64f2dbfe6d33ae0895b23"
},
{
"optionId":"6da09445b5ef419a8e5b98d0ae3da17b"
},
{
"optionId":"f63285d3f23f441c993a2f2aab499082"
},
{
"optionId":"5503ef20a7424bc58facdac2b8ca6ac5"
},
{
"optionId":"24da21ac840d4abbb358d01bb03ad74c"
},
{
"optionId":"a300f872a68f4f93b1af3d6e1c50e397"
}
],
"visibilities": [
{ "id": "9d4a11eeaf3a41bea44fdfb599d57058", "salesChannelId": "6d8478bd752d4c17a19ad3f7e6af851a", "visibility": 30 }
]
}
LG Ben