Adjust inventory quantity variant

EverettZ
New Member
1 0 0
Hi, I am trying to automate the process of uploading products on my store in Node.js and I have troubles upload the inventory quantity. I was able to upload product 'without variants' (default variant) properly by just changing the inventory_quantity. However, for products with multiple variants, I wasn't able to do so. I find out that the function for variants has been deprecated and I am using the new function. However it returns either 401 or 403 for my code below. When I put it on Postman it gives me 200 however nothing has changed.
 
The following are my code in attempt to upload the inventory quantity (available) using proper location_id (there is only one location so it cannot be wrong), inventory_item_id for the item, and basic authorization. Some helps are appreicated :).
 
await axios.post('my_website_name/admin/api/2021-01/inventory_levels/set.json',
            { 
              location_id: my_location_id,
              inventory_item_id: my_inventory_id,
              available : Some_Numbers,
              
                auth:{
                username: "my_authorization_username",
                password: "my_authorization_password"
              }        
            })
0 Likes
samc
Excursionist
32 1 24

Hi!

Without knowing the entire code, it's hard to know exactly what may be the issue.

But a 401 or 403 error code indicates the API credentials are probably not passed in properly. For nodeJS, I recommend to use this library (https://github.com/MONEI/Shopify-api-node) to interact with Shopify APIs.

Additionally, I also recommend trying out a development platform we built for Shopify (Shypyard). The platform makes it dead simple for you to make API requests to your Shopify store. And you can use it to test and build your script easily all within your browser.

 

https://apps.shopify.com/shypyard