Reputation: 47
I am trying to make a post request for this api endpoint I am trying to update multiple product at once, my best try is :
payload = [{
'Sku': '101',
'Quantity': 122,
'WarehouseId': 16
},
{
'Sku': '102',
'Quantity': 126,
'WarehouseId': 15
}
]
url = 'https://ecomdash.azure-api.net/api/inventory/updateQuantityOnHand'
try:
res = requests.post(url, data = payload, headers=headers)
print(res.status_code)
print(res.content)
except Exception as e:
print(e)
It gives me this error: "too many values to unpack" I think I have done something wrong in the payload. headers param is ok as for same value it works when I test from the " api documentation Try It" section. Even when I use this payload,
payload = {
'Sku': '101',
'Quantity': 122,
'WarehouseId': 16
}
The request returns a 200 but the update does not occur. Any suggestion? Thanks in advance!
Upvotes: 0
Views: 963
Reputation: 47
The endpoint accepts data in body, not in data. The correct code is,
res = requests.post(url, json = payload, headers=headers)
Thanks @m01010011 for the hint. I got mixed up in the query parameter and request body. Really appreciate your help.
Upvotes: 2