skip to Main Content

I’ve been struggling to solve a problem for 1 day, but I still can’t figure it out.
I’m trying to load 2 scripts in the header in shopify, but every time I try to do this through the api I get the error "Not Found"
I searched all the forums but I couldn’t find a solution

const asset = new shopify.api.rest.Asset({session: session});

            asset.theme_id = theme.id;

            asset.key = 'layout/theme.liquid';

            asset.value = `
              {{ content_for_header }}
              {{ ' ' | script_tag }}
              ${scripts}
              {{ ' ' | script_tag }}
              {{ content_for_layout }}
            `;

            await asset.save({
                update: true
            });

The path is correct, the theme id is correct, but I still get not found
When I try to find this asset

 [
2023-05-09 10:39:47 │ backend  │   Asset {
2023-05-09 10:39:47 │ backend  │     key: 'layout/theme.liquid',

2

Answers


  1. Starting with Admin API 2023-04, Asset resource PUT or DEL requests are restricted using the write_themes access scope. If an app that’s distributed in the Shopify App Store needs to use Asset resource PUT or DEL requests, then it needs to be granted an exemption by Shopify to use the write_themes access scope
    https://github.com/Shopify/shopify-api-php/issues/261

    Login or Signup to reply.
  2. so did you solve it?, and do i need this "exemption by Shopify" if my app is distributed in the shopify app store?
    thanks

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search