Error reading .json uploaded with filestack API

Using the filestack API documented here:

I am now able to upload files to filestack, get a response w/ the fileId and send it to 8base, it gets registered as a file correctly.

However, I have a trigger that runs on file create.after, which makes a request to that .json file and tries to read it.

This fails with the following error:

2020-02-05T16:16:47.565Z 5f950e06-b4fe-45e7-9829-b42d4bd2db84 ERROR Invoke Error {"errorType":"FetchError","errorMessage":"invalid json response body at,sxxxxxxx/xxxxxxxxseq1 reason: Unexpected number in JSON at position 1","message":"invalid json response body at 

The json file when I uploaded it was pure valid json.

It was uploaded with 'Content-type': 'application/json'

However. When I go to see the file with the link. I see that FileStack has added some stuff at the top of the file. (not sure if this is the cause or not though).

Oddly when I upload a file directly through the app.8base UI it works fine.

So why are my JSON files being corrupted when using the filestack API?

Any ideas what’s going on here?

Hey man, check this out about fetching the file. Also, by any chance do you have the filepicker set to multiple select or single select?


I need to be able to upload 12 .json files at once.

@sebastian.scholl the solution to that github issue doesn’t help too much. But it got me on the right track.

If I remove the Content-Type Header. I get the following error: “Nothing found to store - pass in data or a url”

The upload only seems to work if I put a specific content-type header.

But after digging into the webkitBoundary stuff, I figured out that it was most common with the xhr requests I was making. So I switched it to use fetch and that worked fine.

Glad it got you on the right track! Was the xhr request being made in you serverless function?

No that was frontend.

The default behavior of the Upload React component I was using, was using a standard xhr request…

Set it to use fetch instead of the default POST method.