MONEI / Shopify-api-node

Node Shopify connector sponsored by MONEI
https://monei.com/shopify-payment-gateway/
MIT License
941 stars 278 forks source link

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

Open krjo opened 1 year ago

krjo commented 1 year ago

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"

}
fredbegin11 commented 5 months ago

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.