I’m trying to retrieve .liquid files using the Admin API but every time I attempt this I get a 404 not found error. What’s odd is that if I try to use the same endpoint to retrieve a .json file it works correctly. This seems to contradict the documentation which shows that this endpoint should indeed be able to be used to retrieve .liquid files.
The 404 error suggests that the file you’re looking for does not exist as an asset for the specified theme. You can check this by retrieving a list of all assets for the theme, then ctrl+f searching for the file you’re looking for.
For example, if you’re looking for the templates/index.liquid file, you can use the below curl request and search for that file name:
curl -L -X GET 'https://shop-name.myshopify.com/admin/api/2022-10/themes/YOUR_THEME_ID/assets.json?fields=key' \
-H 'X-Shopify-Access-Token: YOUR_ACCESS_TOKEN'
Keep in mind that this templates/index.liquid file from the docs/example may not be an asset file for your theme. From my testing, this file does not exist for most of my themes.
I’ve tried several different .liquid files that I can verify are all part of the theme and I get the same 404 error in each case. I’ve just tried using the get asset list endpoint and the keys for all of the .liquid files I’ve attempted to retrieve are present in that list. It seems like there’s some kind of bug in the endpoint itself as I can retrieve .json files without issue.
To give some further examples, I’ve just attempted using the following keys to make requests to this endpoint: (also did other file types to show that it doesn’t seem to just be affecting .liquid files)
Here is the full stack trace: (I replaced root file paths to the app with [path])
backend | HttpResponseError: Received an error response (404 Not Found) from Shopify:
backend | If you report this error, please include this id: b210204f-ce51-4b2b-8c19-f6c8c4bab74d
backend | at HttpResponseError.ShopifyError [as constructor] ([path]\web\node_modules\@shopify\shopify-api\dist\error.js:13:28)
backend | at new HttpResponseError ([path]\web\node_modules\@shopify\shopify-api\dist\error.js:104:28)
backend | at RestClient.
Thanks for trying that! If you would kindly share the X-Request-ID (and timestamp) from one of the 404 responses, we can pull the logs (within 7 days) and take a closer look.
If the curl request fetches the file but the request via the shopify-api-node library throws the 404 error, please submit an issue directly in the repo here.