Unable to retrieve contents of specific assets via asset API

devo774
Visitor
2 0 0

I am working on creating an app with this repo: https://github.com/Shopify/shopify-node-app/. Everything is working great in retrieving product data and some data about assets but I am having trouble with retrieving the contents of asset files.

For example, this call works perfectly in retrieving a complete list of theme assets as an object:

https://72926fc0.ngrok.io/shopify/api/themes/38307725370/assets.json

However if I wish to make a call to a specific asset and retrieve its contents (the actual html/js/liquid whatever in the file), according to these docs https://help.shopify.com/en/api/reference/online_store/asset, this call should do it:

https://72926fc0.ngrok.io/shopify/api/themes/38307725370/assets.json?asset[key]=templates/index.liqu...

What's weird is this call just retrieves the same data as the first call which is just a big list of the assets in the theme as an object... but no specific asset contents.

calls like this /products/1977430802490.json inside the demo api console return a product object just fine.

Now I know we are using shopify-api-node for some things, but it doesn't seem to be involved after app init. That's why I was trying out these calls straight from the docs.

The call returns properly if you make a call like this without ngrok:
https://mystore.myshopify.com/admin/themes/38307725370/assets.json?asset[key]=templates/index.liquid

Anyone experience anything similar? What am I missing?

Replies 4 (4)

Visely-Team
Shopify Partner
1843 210 488

Hey there,

Looks like the query string is just not being proxied by ngrok. Try a call to products.json with some query params like fields=xxxxx and validate whether you'll get the payloads limited just to the fields you have listed. If not, then most probably there is a misconfiguration on the ngrok side?

Sergiu Svinarciuc | CTO @ visely.io
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!
- To learn more about the awesome stuff we do head over to visely.io or our blog

devo774
Visitor
2 0 0

Hi, thanks for your response.

Calls for specific customer and product data like this as outlined in the api docs:

https://72926fc0.ngrok.io/shopify/api/customers/1203018498106.json
https://72926fc0.ngrok.io/shopify/api/products/1977430802490.json

These both worth perfectly. I have tried many different version of the query parameter syntax for theme asset contents but still no success.

However I should try adding the asset api query params to a product api call and see what happens.

Also I tried a different tunneling service (a service called "Forward") and it behaved the same as ngrok.

TimBlackDesign
Shopify Partner
42 8 8

Hi, I wanted to check and see if you found a solution for this? I am diving into my first app and hit a wall trying to do the same thing with ngrok.

- If this reply was helpful please click Like to let me know! (and maybe buy me a coffee ?)
- If your question was answered please mark this as an Accepted Solution.
- Learn more about working with Shopify themes
PabloMarchena
Visitor
3 0 0

Not sure if this could be related but looks like it is a access scope problem, as you mentioned you can query your products but not the themes, check this link about setting up those scopes on your app:

https://shopify.dev/docs/admin-api/access-scopes

 

By default the Shopify CLI sets the app only with products permissions, you must add the theme and all other API you want to read/write on your ENV File.