Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more

Re: The problem in saving an asset through api

The problem in saving an asset through api

RecomazeAI
Shopify Partner
5 0 0

Hi, I'm facing a very strange problem that I can't seem to figure out.

I'm trying to make a plugin to insert 2 collection scripts in the current Shopify theme, but every time I get the "Not found" error, but all the inputs are correct, I also checked the theme id and the path of an asset and everything OK

 

const test = await shopify.api.rest.Asset.all({session: session, theme_id: theme.id, asset: {"key": "layout/theme.liquid"}});

 

const asset = new shopify.api.rest.Asset({session: session});
                asset.theme_id = test.data[0].theme_id;
                asset.key = "layout/theme.liquid";
                asset.value = "<img src='backsoon-postit.png'><p>We are busy updating the store for you and will be back within the hour.</p>";
                await asset.save({
                    update: true,
                });

 

 

 

My response

 

2023-05-10 06:11:17 │ backend  │ HttpResponseError: Received an error response (404 Not Found) from Shopify:
2023-05-10 06:11:17 │ backend  │ "Not Found"

 

 

 

Replies 3 (3)

wil_dev
Shopify Partner
12 0 2

Hello,

I have exactatly the same problem, did you found an issue?

Darshan13
Shopify Partner
11 0 2

I have the same issue can you find any kind of solution @RecomazeAI , @wil_dev 
If you find then give the solution.

CharlesMoreno
Shopify Partner
22 0 16

Hi @RecomazeAI,

 

Seems that we have a similar problem. I have posted a workaround while we're waiting for them to fix this. I have reached out to the Shopify Partner regarding this issue and I do recommend you to send out a ticket as well.


Please refer to this link for the workaround:

https://community.shopify.com/c/online-store-and-theme/create-update-using-assets-api-on-shopify-rea...

 

Hope that helps!