REST Api Delete Asset Request not working

Solved
Jason27
Shopify Partner
78 1 25

Hi, I'm trying to DELETE an image asset and its returning "200" OK result but image is still in the asset folder when I verify.

Here's the x-request-id: afc0b7d7-b4b1-4e97-970f-10fa2c374825

Can a Shopify Staff let me know what's the issue?

Cheers

0 Likes
L_J_K
Shopify Staff
Shopify Staff
147 15 24

Hey @Jason27

Thanks for raising this one. I'd checked out the request ID - afc0b7d7-b4b1-4e97-970f-10fa2c374825 and it wasn't an asset delete request by the looks.

In any case though, if this image asset is still present after the browser cache is cleared, if you wanted to supply me with the images "src"  CDN link to the asset, I can purge it from the CDN if the issue persists. 

| API Support @ Shopify |
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!
0 Likes
Jason27
Shopify Partner
78 1 25

Hi @L_J_K,

I don't think its a caching issue since I just looked at the Assets folder again and the image is still there after a few days.

I just ran the script again and this should be the request id:  

d0e62504-b813-4883-9990-31c9a066c78f

The request should be: 

DELETE /admin/themes/198056264/assets.json?asset[key]=assets/pool-9_2693.jpg

Can you tell me what it looks like on your end?

Thanks for looking into it, it's probably something I'm doing wrong, but I can't figure it out.

 

0 Likes
L_J_K
Shopify Staff
Shopify Staff
147 15 24

Hey @Jason27, apologies for the late reply, I was away!

That's super strange - on that request ID it seems you're not hitting the assets.json endpoint at all  - the only controller involved is the auth controller and nothings logged against the assets controller curiously enough. Strange how it's returning 200 OK though, I never see anything but a 200 in the logs.

The structure of your call seems good and I took a look on the store - the asset key is fine too. Silly question but have to ask, are you using the correct access tokens with correct scopes? Does the same thing happen on delete for similarly named assets?

I gather on the 200 OK you're seeing something like this I'd presume?

{
  "message": "assets\/favicon.png was successfully deleted"
}

Please let me know when you get a chance - thanks!

 

| API Support @ Shopify |
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!
0 Likes
Jason27
Shopify Partner
78 1 25

This is an accepted solution.

Ok, thank you for confirming on your end - it forced me to dig deeper. So I tracked down the issue to my Shopify Rest plugin. It's sending the URI in an encoded format, and since DELETING assets is the only endpoint that I use which requires the vars within url parameters, I guess I never came across this issue. If I decode it before sending, it returns the message correctly and the asset is deleted.

It was sending this:

https://leisure-38.myshopify.com/admin/api/2021-01/themes/198056264/assets.json%3Fasset%5Bkey%5D=assets/1-a-a-a-a-test-8740.png

instead of

https://leisure-38.myshopify.com/admin/api/2021-01/themes/198056264/assets.json?asset[key]=assets/1-a-a-a-a-test-8740.png
L_J_K
Shopify Staff
Shopify Staff
147 15 24

Awesome, thanks for confirming @Jason27 glad you got there!  

| API Support @ Shopify |
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!
0 Likes