Expand my Community achievements bar.

Batch Ingestion API upload failure

Avatar

Level 2

I am trying to upload small file using batch ingestion api, in the existing data set via json file.

My json file looks good and valid. I am able to upload same file via UI but unable to upload it via API.

Getting the below error:

Input file: sample.json is not valid JSON file. Expecting the first character to be `[` or `{`, but 'm' is found. Please fix and re-ingest.

 

Sample Json content:

[{"_compname":{"Obj":{"key":"123","ID":"001", "con":"IN", "Name":"test"}}}]

 

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

3 Replies

Avatar

Community Advisor

@info_centre1 Could you add more info? the endpoint you used? 

Were you able to create a batch and followed up with a put request with batch id? 

 

Anil 

Avatar

Community Advisor

Hi @info_centre1 - As @Anil_Umachigi mentioned, it would be good to have more context on this.

Avatar

Employee

When I had seen a similar error the problem ended up being that I was configuring my PUT request wrong. The language in my case is Python. I was setting the Content-Type header to "application/octet-stream" but I was creating the request like:

 

 

response = requests.put(url=url, headers=HEADERS, files={'file': file})

 

 

but what ended up working was:

 

 

response = requests.put(url=url, headers=HEADERS, data=file.read())

 

 

 

My understanding is that using the `files={'file': file}` parameter instructed Python's `requests` to override the Content-Type header and it actually created a `multipart/form-data` request, causing the endpoint to reject the request. Passing the actual file binary (via `file.read()`) using the `data` parameter kept the content type as "application/octet-stream"