Update inventory quantity using REST API for product with no variants

browntaped
Tourist
7 0 3

We have few products in our store which do not have variants. Shopify seems to assign a "default variant" for such products. We are trying to update the quantity of the inventory using the REST API as follows

update_inventory_req = requests.post( "https://%s.myshopify.com/admin/api/%s/inventory_levels/adjust.json" % (SHOP_NAME, API_VERSION), auth=(API_KEY,PASSWORD), json=json.dumps(payload), headers={'Content-Type': 'application/json'}

Where payload is

payload = {"inventory_item_id":14094647492653, "location_id":29563841,"available":1}

 However, we are getting the status code as follows:

(Pdb) update_inventory_req
<Response [403]>
(Pdb) update_inventory_req.reason
'Forbidden'
(Pdb)

FYI:  The above approach works for products which have variants.

Is there anything special to be done for products with no variants?

0 Likes
_JB
Shopify Staff
Shopify Staff
809 95 176

Hey @browntaped,

Http status 403 is usually due to an invalid API key/API secret being used, so it's odd that it's only happening for requests where products have just the default variant. If you can provide the X-Request-ID value from the response headers of your failed calls, I can use that to try and find more information about the error.

JB | Developer Support @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

0 Likes