Modify theme.liquid using Shopify assets API

Refresh

February 2019

Views

8 time

1

I want to add the below-mentioned code in theme.liquid

<div id="shopify-section-header" class="shopify- 
section">
<!-- content of sections/header.liquid -->
<a href="http://pricemonitor.info/cloth_comparision/#/" 
class="site-header__icon site-header__imagesearch">
{{ 'imagesearchlogo.svg' | asset_url | img_tag }}

</a>
</div>

I have tried below-mentioned method in python

data={
"asset": {
"key": "layout/theme.liquid",
"value": '''<div id="shopify-section-header" class="shopify- 
section">
<!-- content of sections/header.liquid -->
<a href="http://pricemonitor.info/cloth_comparision/#/" 
class="site-header__icon site-header__imagesearch">
{{ 'imagesearchlogo.svg' | asset_url | img_tag }}

</a>
</div>'''
}
}
response = requests.put("https://" + session.get("shop")
+ "/admin/themes/42517168241/assets.json",data= 
data,headers=headers)

I have added this script in the Shopify app but I am not getting the proper response

Bellow is a response.

{
"error": "822: unexpected token at 'asset=key&asset=value'"
}

I am unable to add the piece of code in the theme.liquid file

0 answers