Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Re: API try to update inventory using var response1 = await apiClient.PutAsync(apiUrl1, jsonConten

API try to update inventory using var response1 = await apiClient.PutAsync(apiUrl1, jsonContent);

vijaydave
Visitor
2 0 0

this is the format I'm using to send update information :  var jsonContent = new StringContent(
$"{{\"product\": {{\"id\": {product.ProductId}, \"variants\": [{{\"id\": {product.variant}, \"sku\": \"{product.sku}\", \"inventory_quantity\": {product.inventory_quantity}}}]}}}}",
Encoding.UTF8,
"application/json"
); 

with put request getting sucesscode but it is not updating product.inventory_quantity

Replies 3 (3)

Liam
Community Manager
3108 344 910

Hi Vijaydave,

 

I believe you'll need to use the InventoryLevel resource to update a products inventory as the inventory_quantity on product variants is read only. 

Liam | Developer Advocate @ 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

vijaydave
Visitor
2 0 0

Thanks , Liam for Replaying .. So I have to call Post Api insted of the Put or Patch Api to update inventory Quantity .  that I understand from this example is it correct ??  and from here I'm calling Post Api with adjust.json one so it require Location Id but we have only one location so i do not have location id..  so there are two endpoint to update inventory quantity adjust.json and set.json both require location id .

vijaydave_0-1703002107681.png

 

Liam
Community Manager
3108 344 910

You can get the inventory_item_id via the inventory item resource

Liam | Developer Advocate @ 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