Stock updates through REST API not working, product ID's seem to be changing?

rclark
Shopify Partner
5 0 1

 

For one of our clients we have developed an integration where we keep stock of products up-to-date through external sources, by using the REST API.

 

Now this client already had many products in their shop previously which also need to be mapped, so they performed a product ID/inventory item ID export which we imported on our end.

For some reason however, it appears that many of these products can then not be found (404), so stock updates are failing.

 

Upon further inspection by comparing the provided ID export + using the API to get the product (GET /products/{id}.json), the product was found just fine but the variant ID and inventory item ID received from the API were completely different.

 

The client assures us that they don't manually move/duplicate products or anything like that, but I can't see any other reason for this happening.

 

 

What could cause this?

Replies 5 (5)

ShopifyDevSup
Shopify Staff
1435 234 488

Hey @rclark - thanks for getting in touch. You're on point here. The inventory item IDs and variant IDs should generally only "change" if the variant itself is either deleted and then "remade". I'd recommend getting in touch with Partner Support through your Partner dashboard if the issue is still ongoing, since we would likely need to discuss some store-specific private information that we can't surface on the forums. 

That said, a likely reason for this might be another app or integration they're using for inventory management (it could be that an app is modifying variants, etc. for their processes without the merchant necessarily being aware, if that makes sense). Without knowing more (and with privacy in mind), it's hard to tell, so I'd definitely say getting in touch with Partner Support is the best next step here. Our Partner Support team can get in touch with our technical teams (like mine) and we can troubleshoot with them to look into issues like this. 

 

We'd generally need some examples of the issue like an X-Request-ID for one of those 404 errors, a time frame for the issue and potentially the payload body of the request and response if possible. If it's a case of another app influencing the process, we would need the merchant to provide permission for us to share that information with you as well - so I just wanted to mention that too. If that's the case, you may need to request collaborator access to the shop for privacy purposes. 

I'd share the above info with Partner Support and link them to this thread - it should help speed up the investigation process. 

Hope this helps and hope to hear from you soon if the issue is still persisting - happy to look into this further.

 

Al | Shopify Developer Support 

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us 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

rclark
Shopify Partner
5 0 1

Thank you very much for your reply.

 

I was also suspecting an external app or integration which may be getting in our way.

 

I will forward the client to the partner support, for now there is no further action required.

 

Hope we will be able to identify the culprit.

rclark
Shopify Partner
5 0 1

Hi Al,

 

It appears that this is happing for many more of our clients, since about a month.

 

Any ideas what may cause this?

 

Changes in the API, maybe a known issue?

 

Hope to hear from you, thanks.

ShopifyDevSup
Shopify Staff
1435 234 488

Hey @rclark 

Appreciate you reaching back out. We were able to do some testing with the REST APIs, both querying and updating inventory data, however everything seems to be working as expected in our test environments. 

Since you are still experiencing unexpected behaviors, the most effective way to resolve this will be opening a support ticket with our Partner Support team directly, as Al recommended in the previous reply. Below are some important details that Partner Support will require to further investigate - please share the most recent examples possible (generally from within the last 7 days).

  • A query (GET) to confirm expected details that aren't accepted and  any subsequent (PUT) requests attempting to make the change
  • Timestamps or approximate timeframes (date response header value)
  • x-request-id header values
  • Returned error codes and bodies
  • Request body (for PUT request)
  • Endpoint URLs (including "store.myshopify.com")

From your Partner Dashboard, head to the Support menu and follow the link. Feel free to reference this forum post as a reference when working with Partner Support. 

Best,
Shopify Developer Support

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us 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

rclark
Shopify Partner
5 0 1

Hi there,

 

It appears that I have found the reason this is happening.

 

When a user creates an option, for example after we created the product, they add "Color: Green", the variant is deleted and recreated!

 

This changes the underlying variant and inventory item IDs, which ensures that our integration will not function.

 

As I said, it appears that this is a new issue since a few months.

Did anything change in the working of your backoffice?

 

See screenshot where the user added the colour of the product:

Screenshot 2023-07-10 at 16.05.16.png