deprecated inventoryQuantity set api

Highlighted
New Member
7 0 0

Our app show error message inventoryQuantity and inventoryQuantityAdjustment is deprecated  https://prnt.sc/tied85 .

1) So now we can't use Api "inventory_levels/set.json" from App?.

2) Is there any way that we can set quantity of variants now?

Can you please guide about this.

Thanks

0 Likes
Highlighted
Shopify Partner
541 39 110

If you drill into the specifics in the documentation, you will see that you need to iterate through the various locations to set the quantities there. See https://shopify.dev/docs/admin-api/rest/reference/inventory/inventorylevel?api[version]=2020-07#adju... for the details.

0 Likes
Highlighted
New Member
7 0 0

But I am already using 'location_id' parameter in  '/inventory_levels/set.json' Api    https://shopify.dev/docs/admin-api/rest/reference/inventory/inventorylevel?api[version]=2020-07#set-...

Am I missing anything else?

 

0 Likes
Highlighted
Shopify Partner
541 39 110

You are missing not including your JSON request body and the full API URL you are trying Sanitized of course. Maybe if other eyes see what you are passing into the API request it will shed some light... 

0 Likes
Highlighted
Tourist
6 0 0

Hi @brstdev3 !

I think that maybe you should not send the parameters of inventoryQuantity and inventoryQuantityAdjustment because they are now deprecated fields (starting 1st July), and it would send you an error if you try to update or set the inventory in the endpoint of ProductVariant. So, now we have to use just the endpoints for Inventory to set or update this field. That's what I understood about this change, but maybe @Greg_Kujawa could help us.

I hope this was helpful for you

Kind regards!

0 Likes
Highlighted
Shopify Partner
541 39 110

Without a listing of what exactly what API request is being sent, it's not obvious as to what the issue is. Can the OP please paste in the JSON request body of what is being sent? If you look in the REST API docs that I linked, you will see a working example. Specifically, to adjust available inventory for a specific location, the JSON request body would look like this (see below). Keeping in mind that the inventory_item_id is not the same as the unique ID for the overall variant. Each location has its own unique inventory item ID for the variant at that particular location. If you query the variant itself you can see the inventory_item_id for the variant at each site...

 

POST /admin/api/2020-07/inventory_levels/set.json
{
  "location_id": 905684977,
  "inventory_item_id": 808950810,
  "available": 42
}

 

 

1 Like
Highlighted
Tourist
6 0 0

Sure, @Greg_Kujawa  is right, it would be better if you share the JSON of your request @brstdev3 . 

0 Likes
Highlighted
New Member
7 0 0

Yes , I am sending parameters like this

POST /inventory_levels/set.json
{
"location_id": 905684977,
"inventory_item_id": 808950810,
"available": 42
}


0 Likes
Highlighted
New Member
7 0 0

Also My app show error as you can see in screenshot https://prnt.sc/tmdb2n .

And error link goes to https://shopify.dev/tutorials/migrate-your-app-to-support-multiple-locations .

Here I can see https://prnt.sc/tmdbya "set inventory_quantity or inventory_quantity_adjustment on the product variant is deprecated". 

 

But in shopify documentation https://prnt.sc/tmde1y   https://shopify.dev/docs/admin-api/rest/reference/inventory/inventorylevel?api[version]=2020-07#set-... 

"/inventory_levels/set.json" api is still there.

So now are these "inventory_quantity " Apis deprecated  or still we can use this?

 

0 Likes
Highlighted
Shopify Partner
541 39 110

Your screen shots appear to just be of the Shopify API documentation. And your JSON request body just appears to be a copy/paste of my example. Can you please share your API request, with headers and body? You can sanitize it to remove your shop name and other identifiers.

You need to verify in your JSON request body that the location_id is correctly specified, the inventory_item_id indeed matches up with the particular variant at that location, etc. The API response you get back from Shopify should indicate at least a little bit about what the issue is. Pasting that API response with headers in your reply would be likewise helpful. 

0 Likes