Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Upload JSon from API ?

Solved

Upload JSon from API ?

JoDev1
Shopify Partner
4 1 7

Hello, i got a problem i create upload files for my themes all work good for liquid css js etc but when it s a json file it s crash, I use this api 

 

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

I try with multiples Json and all time this issue

Received an error response (400 Bad
Request) from Shopify:
{
}
"value": "expected Hash to be a String"
If you report this error, please include this id:
312c4c8e-1979-47e5-82ce-2acc2cf349ed'.

or Expected array to a string


Thanks for your help 

Accepted Solution (1)

JoDev1
Shopify Partner
4 1 7

This is an accepted solution.

I use this code` @ShopifyDevSup 

 

const freshFileObj = await this.getFileInfos(file.path);

const response = await axios.get(freshFileObj.download_url);
const asset = new this.shopifyApi.rest.Asset({ session: this.session });
 
    asset.theme_id = liveTheme.id;
    asset.key = freshFileObj.path;
    asset.value = response.data;
    await asset.save({
      update: true,
    });

View solution in original post

Reply 1 (1)

JoDev1
Shopify Partner
4 1 7

This is an accepted solution.

I use this code` @ShopifyDevSup 

 

const freshFileObj = await this.getFileInfos(file.path);

const response = await axios.get(freshFileObj.download_url);
const asset = new this.shopifyApi.rest.Asset({ session: this.session });
 
    asset.theme_id = liveTheme.id;
    asset.key = freshFileObj.path;
    asset.value = response.data;
    await asset.save({
      update: true,
    });