Expand my Community achievements bar.

Join us on September 25th for a must-attend webinar featuring Adobe Experience Maker winner Anish Raul. Discover how leading enterprises are adopting AI into their workflows securely, responsibly, and at scale.

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

Employee

@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"