All things Shopify and commerce
I'm attempting to update an asset in my store using an API. All GET requests function correctly, but when I attempt to perform an update (PUT) or deletion, the API returns the list of assets instead of performing the intended update or deletion on the asset. Here's an example:
I've reviewed the permissions of my app, which currently include "write_themes" and "read_themes" access. I have another store where the same code works. This leads me to believe that the issue might stem from a configuration setting within my Shopify setup.
I tried various API versions, from 2022-10 to 2013-10. I also deleted and recreated the app, but unfortunately, none of these steps have yielded successful results.
This error also manifests in other endpoints, such as when attempting to create or update an order.
Solved! Go to the solution
This is an accepted solution.
I sent to Shopify developers and they clarified the problem:
Merchants can change their .myshopify.com domain once, but it doesn't actually change the old one, it makes a new one and some things redirect back to the old one.
With API requests you get redirected to the original .myshopify.com domain for the store, and some HTTP clients will change POST/PUT requests to GET requests when handling the redirect. So if you take a really close look at yout logs you should notice that those requests that return a list of all the assets are actually GET requests to a different domain than what they originally reached out to.
For me it is an unexpected behavior. I ask to them if they plan to correct this behavior.
Solution: Use the original .myshopify.com instead of renamed .myshopify.com and it will work
I would recommend posting this in Shopify Discord Server.
I posted there, no response
More information:
When I get both response headers (one working) it is missing Location Headers and the X-XSS-Protection is also wrong. It is ignoring the path, don't know why.
PHP example code:
This is an accepted solution.
I sent to Shopify developers and they clarified the problem:
Merchants can change their .myshopify.com domain once, but it doesn't actually change the old one, it makes a new one and some things redirect back to the old one.
With API requests you get redirected to the original .myshopify.com domain for the store, and some HTTP clients will change POST/PUT requests to GET requests when handling the redirect. So if you take a really close look at yout logs you should notice that those requests that return a list of all the assets are actually GET requests to a different domain than what they originally reached out to.
For me it is an unexpected behavior. I ask to them if they plan to correct this behavior.
Solution: Use the original .myshopify.com instead of renamed .myshopify.com and it will work
Thanks so much for this, Andretrevas. We had this same issue and I've been hunting for the problem and solution for a few days. Your solution worked for my case as well. Thanks for sharing.
Starting a B2B store is a big undertaking that requires careful planning and execution. W...
By JasonH Sep 23, 2024By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024