Unable to Update Inventory using Python etsy2

82 views
Skip to first unread message

Rookie

unread,
Dec 7, 2021, 1:26:00 PM12/7/21
to Etsy API
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:

You can take the returned value from getInventory, modify it, and send it back again with updateInventory.

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.

david olick

unread,
Dec 7, 2021, 2:36:06 PM12/7/21
to Etsy API V2
What is an example JSON string you are sending?


--
You received this message because you are subscribed to the Google Groups "Etsy API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to etsy-api-v2...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/etsy-api-v2/d0bb9dfd-2b2c-4ae4-8931-4c36a1c3cea0n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages