I am using ASSET RESTAPI to update the storefront asset, but I am getting 404 not found error. I have also given the write_themes access scope but still not working. I have no issue getting all assets. Please tell me the solution or any alternative, Basically, I have to add/edit/delete the templates using API.
This is Gina from the flareAI app helping Shopify merchants get $6Million+ in sales from Google Search, on autopilot.
If you encounter a 404 Not Found error while using the Asset REST API to update a storefront asset in Shopify, here are a few suggestions you can try:
Ensure the accuracy of the asset key
Make sure the asset key you provide in the API request is correct. The asset key should include the file extension, such as “my-template.liquid” or “my-stylesheet.css”.
Make sure the theme ID is valid
Double-check that you specify the accurate theme ID in the API request. You can retrieve the theme ID by using the “List themes” API endpoint. If you try to update the asset in the wrong theme, you’ll receive a 404 error.
Verify the granted access scope for write_themes
Ensure that you have properly granted the “write_themes” access scope to your API credentials. You can check this in your Shopify Partner Dashboard by selecting the app and navigating to the “App setup” section. If you recently updated the access scopes, regenerate the API credentials and make sure they are correctly configured.
Check if your API credentials have the necessary permissions
Verify that the API credentials you are using have adequate permissions to access and modify storefront assets. You can review the permissions assigned to your API credentials in the Shopify Partner Dashboard.
Verify asset existence
Before attempting to update an asset, confirm that it actually exists in the specified theme. You can use the “List assets” API endpoint to retrieve a list of all assets in a theme and verify the presence of the asset you want to update.
Please don’t hesitate to reach out if you require any additional assistance.
I have done all things you mentioned above, but the problem is not solved yet, please let me know if any solution you found. I am working on a development store and have given the write_theme scope.
Hey @PROGRAMMER123 and @talha_dev I’m running into a similar issue (although I am not trying to write anything on the theme just read it which you seem to have figured out)
Found this in the Documentation here when searching for my issue:
“Starting with Admin API 2023-04, Asset resource PUT or DEL requests are restricted using the write_themes access scope. If an app that’s distributed in the Shopify App Store needs to use Asset resource PUT or DEL requests, then it needs to be granted an exemption by Shopify to use the write_themes access scope.”
Looks like you’ll need to get specific access from Shopify to be able to do what you are trying to do. That document does list a bunch of work arounds though. Hope this helps you some.
I believe they are de-listing any app that uses depreciated API calls sometime soon this year and/or not allowing them to be published on the App Store. Not sure how it would shake out for a Custom App on your own storefront but I suspect there would be issues eventually as they are pushing everyone towards using Theme App Extensions to get anything into the Theme since the switch to 2.0
How, you solve this issue?. I face this issue in my app when I use PUT request for update an asset in 2024-01 API version. and i get 404 error NOT FOUND.