How can I send the path_body to update quantities via the SP API of Amazon Seller Central in Python?
For example, I have this code:
request_params = {
"MarketplaceIds": marketplace_id, # required parameter
"CreatedAfter": (
datetime.datetime.now() - datetime.timedelta(days=60)
).isoformat(), # orders created since 30 days ago, the date needs to be in the ISO format
}
#UPDATE QTA
def update_inventory():
url = "https://sellingpartnerapi-eu.amazon.com/listings/2021-08-01/items/XXXXXXXX/1AAA-3333-VVVV"
headers = {
"x-amz-access-token": access_token,
"Content-Type": "application/json",
"x-amz-date": datetime.datetime.utcnow().strftime("%Y%m%dT%H%M%SZ"),
"Host": "sellingpartnerapi-eu.amazon.com",
"x-amz-marketplace-id": marketplace_id, # My marketplace ID
}
patch_body = {
"marketplaceIds": "APJ6JRA9NG5V4",
"patches": [
{
"op": "replace",
"path": "/attributes/fulfillment_availability",
"value": [
{
"quantity": 1,
"fulfillment_channel_code": "DEFAULT",
}
]
}
]
}
response = requests.patch(url, headers=headers, data=json.dumps(patch_body))
return response.json()
In the PATCH operation, what am I doing wrong?
I’m getting an InvalidInput error, and I’m unsure how to create calls to update data, while I have no issues with regular GET requests.
New contributor
Vladimiro De Luca is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.