Inventory Item Id missing

Highlighted
New Member
1 0 0

Hi 

 

We are using the API to update a product variant and also the cost price of the variant.  The latter is stored on the inventory_item.  We take the following approach

1.  Find the product id we need by SKU using GraphQL

2.  GET the product by ID

3. PUT the update to the product and variant

4.  As the inventory item id can change at this point, get the inventory item id of the variant from the response to 3

5. PUT an update to the cost price to the new inventory item ID.

We often get a 404 at this point - so the API is saying that inventory item doesn't exist even though it's just told us the ID.  Are we doing this wrong somehow?

Below is the API call for steps 3 & 5 along with the x-request ids in case anybody from Shopify staff can take a look.  

PUT /admin/api/2020-01/products/5731273670810.jso

request_body" => array:1 [▼
"product" => array:19 [▼
"id" => 5731273670810
"title" => "New Lion Bamboo 5 pc Set"
"body_html" => ""
"vendor" => "eddingtons"
"product_type" => "kids"
"created_at" => "2020-09-14T16:21:35+01:00"
"handle" => "lion-bamboo-kids-5pc-set"
"updated_at" => "2020-11-18T14:36:22+00:00"
"published_at" => null
"template_suffix" => null
"published_scope" => "web"
"tags" => "category: kids"
"admin_graphql_api_id" => "gid://shopify/Product/5731273670810"
"variants" => array:1 [▶]
"options" => array:1 [▶]
"images" => []
"image" => null
"status" => "active"
"published" => true
]
]

   "x-request-id" => "c2c4a48d-93d5-4e66-9da8-6ea79011d5a2

"response_body" => array:1 [▼
"product" => array:17 [▼
"id" => 5731273670810
"title" => "New Lion Bamboo 5 pc Set"
"body_html" => ""
"vendor" => "eddingtons"
"product_type" => "kids"
"created_at" => "2020-09-14T16:21:35+01:00"
"handle" => "lion-bamboo-kids-5pc-set"
"updated_at" => "2020-11-18T14:52:03+00:00"
"published_at" => "2020-11-18T14:52:02+00:00"
"template_suffix" => null
"published_scope" => "web"
"tags" => "category: kids"
"admin_graphql_api_id" => "gid://shopify/Product/5731273670810"
"variants" => array:1 [▼
0 => array:26 [▼
"id" => 37591225237691
"product_id" => 5731273670810
"title" => "Default Title"
"price" => "12.95"
"sku" => "5055922004280"
"position" => 1
"inventory_policy" => "continue"
"compare_at_price" => null
"fulfillment_service" => "manual"
"inventory_management" => "shopify"
"option1" => "Default Title"
"option2" => null
"option3" => null
"created_at" => "2020-11-18T14:52:03+00:00"
"updated_at" => "2020-11-18T14:52:03+00:00"
"taxable" => true
"barcode" => null
"grams" => 1000
"image_id" => null
"weight" => 1.0
"weight_unit" => "kg"
"inventory_item_id" => 39684201971899
"inventory_quantity" => 0
"old_inventory_quantity" => 0
"requires_shipping" => true
"admin_graphql_api_id" => "gid://shopify/ProductVariant/37591225237691"
]
]
"options" => array:1 [▶]
"images" => []
"image" => null
]

So inventory item id should be inventory_item_id" => 39684201971899

 

PUT /admin/api/2020-01/inventory_items/39684201971899.json

"request_body" => array:1 [▼
"inventory_item" => array:2 [▼
"id" => 39684201971899
"cost" => "5.18"
]

 

"status" => 404

"x-request-id" => "90dc0cff-a2ac-47f6-85cc-39938c47ba9d"

"response_body" => array:1 [▼
"errors" => "Not Found"
]

 

0 Likes
Highlighted
Shopify Staff
Shopify Staff
15 3 1

@stevenbrookes,

Happy to help out with this issue.

I've reviewed the logs and simulated your workflow on my own and was unable to create the scenario where the inventory item update would return a 404.

When reviewing the logs I noticed the particular product (from the request-ids) is no longer available on the store. I just wanted to check in and see if you were successful in achieving what you needed for your solution.

If you any further difficulties on this issue please don't hesitate to reach out.

Regards,

John

John C | Developer Support Specialist @Shopify
0 Likes