Failing to update Inventory

49 views
Skip to first unread message

Csaba Saranszky

unread,
Oct 24, 2022, 8:35:51 AM10/24/22
to Etsy API
Hi,

I'm using python and etsy2 to try to update the inventory, but failing to do that.

My test code looks the following:

# getting the inventory:
ll = eapi.getInventory(listing_id=int(l.etsy_id))

ll.keys()
RESULT: dict_keys(['products', 'price_on_property', 'quantity_on_property', 'sku_on_property'])

#ll['products'][0]
{'product_id': 6490481917,
 'sku': '2410187731',
 'property_values': [{'property_id': 513,
   'property_name': 'Colors',
   'scale_id': None,
   'scale_name': None,
   'values': ['Athletic Heather'],
   'value_ids': [74650027590]},
  {'property_id': 514,
   'property_name': 'Sizes',
   'scale_id': None,
   'scale_name': None,
   'values': ['XS'],
   'value_ids': [71931464861]}],
 'offerings': [{'offering_id': 6590510769,
   'price': {'amount': 1785,
    'divisor': 100,
    'currency_code': 'EUR',
    'currency_formatted_short': '€17.85',
    'currency_formatted_long': '€17.85 EUR',
    'currency_formatted_raw': '17.85'},
   'quantity': 58,
   'is_enabled': 1,
   'is_deleted': 0}],
 'is_deleted': 0}


#Making some change on the prices (prices dictionary becomes an integer):

for x in ll['products']:
    x['offerings'][0]['price'] = x['offerings'][0]['price']['amount'] + 1


ll['products'][0]['offerings']
[{'offering_id': 6590510769,
  'price': 1786,
  'quantity': 58,
  'is_enabled': 1,
  'is_deleted': 0}]


And trying to update the Inventory fails:

eapi.updateInventory(listing_id=int(l.etsy_id), products=json.dumps(ll['products']))

with:

ValueError: Could not decode response from Etsy as JSON: status_code: 400, text: 'price must be consistent across all products', url 'https://openapi.etsy.com/v2/listings/983293240/inventory'

.

I do have listings_w permission scope, I'm able to update for instance title, tags, pictures.

Could anybody highlight me what am I missing?

As far as I can trace the call calls this url:


with PUT method and a data argument, which is a dictionary



Thanks.
Reply all
Reply to author
Forward
0 new messages