# Upload JSon from API?

**URL:** <https://community.shopify.com/t/upload-json-from-api/239860>\
**Category:** Graphql Basics And Troubleshooting\
**Tags:** optimization\
**Created:** [August 10, 2023, 1:59am UTC](https://community.shopify.com/t/upload-json-from-api/239860 "2023-08-10T01:59:51Z")\
**Posts on this page:** 2\
**Page:** 1

## AI-generated summary

Problem: Uploading a JSON theme asset via Shopify’s REST Asset API fails, while Liquid/CSS/JS uploads work.

Observed errors:
- HTTP 400 Bad Request with empty body.
- Error messages: "value: expected Hash to be a String" and "Expected array to a string".

Implementation details (central code):
- Fetches the file from a download URL with axios (response.data).
- Creates a new shopify.rest.Asset with session, sets theme_id to the live theme, key to the file path, and value to response.data, then calls asset.save({ update: true }).

Context and implications:
- Errors indicate the API expects the asset value to be a String for JSON uploads, but the provided value may be an object/array.

Status: No confirmed resolution or workaround in the thread. Key open question: how to correctly format and send JSON content (value) when uploading theme assets via the REST API.

<div class="post-metadata">

**Author:** ![JoDev1](https://avatars.discourse-cdn.com/v4/letter/j/3d9bf3/32.png) [@JoDev1](https://community.shopify.com/u/JoDev1)\
**Post date:** [August 10, 2023, 1:59am UTC](https://community.shopify.com/t/upload-json-from-api/239860/1 "2023-08-10T01:59:51Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![JoDev1](https://avatars.discourse-cdn.com/v4/letter/j/3d9bf3/32.png) [@JoDev1](https://community.shopify.com/u/JoDev1)\
**Post date:** [August 10, 2023, 5:57am UTC](https://community.shopify.com/t/upload-json-from-api/239860/2 "2023-08-10T05:57:33Z")

</div>

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,  
});
