Shopify-api-node icon indicating copy to clipboard operation
Shopify-api-node copied to clipboard

Help with shopify.asset.create - Shopify API version 2023-04

Open krjo opened this issue 2 years ago • 1 comments

I can't get shopify.asset.create to add a new file to a theme. I know the theme ID is correct as I am able to use asset.get to retrieve a file. But asset.create and asset.update both return 404 errors. I'm using the same params that other posts have shown to be successful. Does anyone see what's wrong?

const asset = {
    key: "snippets/test.liquid",
    value: "Content"
  }

  await shopify.asset.create(themeId, asset)

Response:

{

  "errors": "Not Found"

}

krjo avatar May 20 '23 20:05 krjo

Hey!

I know I'm 6 months late, but Shopify made some changes to the asset API starting from 2023-04.

Ref: https://shopify.dev/docs/api/admin-rest/2023-04/resources/asset

Starting with Admin API 2023-04, if an app distributed through the Shopify App Store uses the Asset resource to create, edit or delete a theme's asset, you need to request the required protected access scope. In most cases, you shouldn't use the Asset resource. To learn more about when you can use the Asset resource, and how to migrate, refer to the [Asset resource](https://shopify.dev/docs/apps/online-store/other-integration-methods/asset).

Basically, starting in 2023-04, you can't update or delete assets anymore without Shopify granting you the required access scopes.

I guess this is why shopify-api-node is throwing 404's on those endpoints.

fredbegin11 avatar Jan 17 '24 15:01 fredbegin11