Focusing on managing products, variants, and collections through the API.
Pretty new to this so apologies if this is an easy to solve problem, but I haven't had any luck searching around. I'm attempting to toggle an item to "Track quantity" and can't seem to do so. I've tried a direct PUT request as well as using the python Shopify API. Here's my PUT request:
Solved! Go to the solution
This is an accepted solution.
After further experimentation, I figured it out! I did some testing and confirmed my code works when run standalone, which confused me. Turns out it's the python Shopify API that was causing this issue. Since I am creating a session and didn't clear that session, my REST API calls were just getting ignored I guess. I modified my program to collect a list of all of the products that need to have inventory tracking turned on, then execute that at the end after clearing my session, and it works! For any future Googlers, clear your session with
Hi Aevumkairos,
It seems like you're doing everything, based on the Shopify API documentation. One thing that I see could be a potential issue is the URL you're using for the PUT
request. In your code, you're using the same URL for GET
and PUT
requests. According to the InventoryItem documentation, the for PUT
request should be https://XXXXXX.myshopify.com/admin/api/2023-10/inventory_items/{inventoryItemId}.json
where {inventoryItemId}
is the ID of the inventory item you want to update.
Given that you're getting a 200 response, it suggests that the server successfully processed your request, but the changes aren't saved or applied. It could be that the inventory item is getting updated but the product isn't.
Another possible issue could be the permissions set in your Shopify private app. If you haven't already, make sure your app has the write_inventory
access scope.
Hope this helps!
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
This is an accepted solution.
After further experimentation, I figured it out! I did some testing and confirmed my code works when run standalone, which confused me. Turns out it's the python Shopify API that was causing this issue. Since I am creating a session and didn't clear that session, my REST API calls were just getting ignored I guess. I modified my program to collect a list of all of the products that need to have inventory tracking turned on, then execute that at the end after clearing my session, and it works! For any future Googlers, clear your session with
Great to hear you figured this out Aevumkairos!
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