Uploading snippet file through API

Highlighted
Shopify Partner
1 0 0

I'm trying to figure out how to add a file in the snippet directory over the API. Is that possible? Can't find anything about it in the docs for Theme (http://docs.shopify.com/api/theme). ;

What I'm trying to accomplish is a way to give the shop owner an easy way to display a small box where he/she sees appropriate with content that my app delivers. My thought was to have a div tag and some javascript in a snippet, which would be easy to place and then build up the content of the box (div tag) with jquery. Much like Linkcious does on my product page.

0 Likes
Highlighted
Shopify Staff
Shopify Staff
582 0 48

What you are looking for is covered in the Asset reference

PUT https://shop/admin/themes.json

{
  "asset": {
    "key": "snippets/yoursnippet.liquid",
    "value": "liquid snake"
  }
}

 

0 Likes
Highlighted
New Member
3 0 0

I am getting 404 error not found .

shopify.put(`/admin/themes/${id}/assets.json`, {
asset: {
key: 'snippets/yoursnippet.liquid',
value: constructButton.Visulabutton()
}
}, function (err, data, headers) {
if (err)
console.log("Error", err)
else
console.log("Data:", data);

});

0 Likes
Highlighted
New Member
2 0 0

Hey, im trying to do the same, but at the moment i have no idea, I see that you are using

 1233.png

but i don't know what package you are using because if you try to get the data through plain html it won't work. What is that "shopify" that you are using, is it app bridge? 

0 Likes