REST API Duplicate Asset Endpoint Not Working

Solved

REST API Duplicate Asset Endpoint Not Working

John_Schulz
Shopify Partner
20 1 7

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.

😞

Accepted Solution (1)

John_Schulz
Shopify Partner
20 1 7

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"
  }
}

 

View solution in original post

Reply 1 (1)

John_Schulz
Shopify Partner
20 1 7

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"
  }
}