I am having difficulties updating inventory via the etsy2 package for Python. When I call update_inventory, I get an error reported that appears to indicate that I haven't specified the product correctly:
"Value for products was not a valid JSON string."
According to the documentation here:
I am trying to do this via the Python etsy2 package here:
I believe that I have the correct permission scopes specified for my oauth, as I am able to see inventory in listings queries. The relevant snippet of code is below. I get the inventory for a given listing, then step through the product offerings. If a product matches the sky that I am looking for, I adjust the quantity. From the pprint statements, the adjustment appears to be correct. I then attempt to call updateInventory and pass the products in, which is where the error is reported.
inventory = etsy.getInventory(listing_id=listing_id)
pprint(inventory)
for product in inventory['products']:
if product['sku'].upper() == sku:
product['offerings'][0]['quantity'] += adjustment
pprint(inventory)
print("Updating")
etsy.updateInventory(listing_id=listing_id, products = inventory['products'])
Do I need to change the format of the inventory['products'] before passing to the updateInventory method? It doesn't appear to be symmetric between the getInventory return value and the updateInventory parameters.