Not able to modify theme using asset api

I am using the following command to modify a theme.

curl -d ‘{“asset”:{“key”:“templates/page.abcd.json”,“value”:“Hello World”}}’ -X PUT https://key:token@mystore.myshopify.com/admin/api/2023-04/themes/{theme-id}/assets.json

I have ensured that sufficient privileges have been given to the app, i.e., Admin API access scopes:

write_script_tags, read_script_tags, write_discovery, read_discovery, write_files, read_files, write_product_listings, read_product_listings, write_product_feeds, read_product_feeds, write_products, read_products, write_publications, read_publications, read_themes, write_themes, write_online_store_pages, read_online_store_pages

This does not give any error and when I check the template, it does not get modified also. Please help.

Its not working from the app also.

Hey there, not sure if you are aware of this already but Asset API access in API version 2023-04 is only available if Shopify has specifically granted you an exemption, even if the app technically has the correct permissions.

Sounds like they could have better error handling here, but I suspect this may by your problem.

1 Like

Hi @aPuneet ,

When using curl if it doesn’t provide any reply then adding a -v parameter for verbose mode will show more information, in this case we were able to replicate no reply with that particular curl command format and verbose mode shows a 406 error.

The quick fix was to add the content type to the curl command in a header parameter like this:

-H ‘Content-Type: application/json’

This is a good time to mention that putting the login credentials in the URL is insecure and instead just the API token should be added to the header with another header parameter like this:

-H ‘X-Shopify-Access-Token: {access_token}’

This is mentioned in the REST tab of the example on the [Access tokens for custom apps] doc page which has a small curl example.

We did also test with a draft public app under the [new restrictions for such apps using the Asset API] and got a proper missing permissions error so that seems to be working ok.

Hope you have a great day,
Jon551

I have also facing this issue when i update my admin api 23-01 to 23-04.how to fix this issue.please help me.

Thanks

Hi, I am going to develop a preloader app, if i use theme app extension, pre loader load milliseconds later. so I want to push html structuer, css, and js using asset api, how can i get permission from shopify, you told “Shopify has specifically granted”
Thanks

How can i get permission? or when shopify granted ?

Hello @Brett_Helium If I use the older API version such as 2023-01, do I need to request an exemption? And does even the 2023-01 API support till now?

Thanks for the reply!