REST API Duplicate Asset Endpoint Not Working

Solved
John_Schulz
Shopify Partner
11 1 3

I'm not sure what or when this changed but I’m no longer able to make a PUT request to /admin/api/{VERSION}/themes/{THEME_ID}/assets.json with a post body like this, as depicted in the docs:

 

 

{
  "asset": {
    "key": "layout/alternate.liquid",
    "source_key": "layout/theme.liquid"
  }
}

 

 


I get the following error no matter what the file I’m trying to create or duplicate from source:

 

 

{
    "errors": {
        "asset": [
            "Template type 'alternate' does not support liquid templates"
        ]
    }
}

 

 

 

Unfortunately, this is definitely a breaking change.  I haven’t changed any code in my app, have replicated this issue in Postman, and have tried all supported API versions and nothing changes…same result.

0 Likes
John_Schulz
Shopify Partner
11 1 3

This is an accepted solution.

In case this helps anyone, it turns out Shopify did make a change that I still don't see documented.

On January 8th 2021 a fix was implemented that is now enforcing a naming convention for template type theme assets.

When using the Asset API you'll now need to enforce the template type as part of the key. So for example, if you were creating a new 404 template the duplicate rest payload to the Asset endpoint might look something like this.

{
  "asset": {
    "key": "templates/myfile.alternate.liquid",
    "source_key": "templates/myfile.liquid"
  }
}

 

0 Likes