Newline is missing when adding file in bulk API

I want to add the following line which is in a separate JSON file using the bulk API

{"index":{"_id":"53e23f5ae4b0ef99cb360835"}}

I use the command

curl -XPOST -H 'Content-Type: application/json' localhost:9200/cheapest_offers/_bulk --data-binary Downloads/test/test.json

And get the error

{"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"The bulk request must be terminated by a newline [\n]"}],"type":"illegal_argument_exception","reason":"The bulk request must be terminated by a newline [\n]"},"status":400}

PS: The file clearly contains an empty line at the end!

Can anyone explain this?

Could you share your file here?

what is the best way to do that? sorry I'm new to this site

Copy the full content as it is to gist.github.com
Or share it on whatever sharing binary site

Is that the only line in your file? Where is the data you want to index? Have a look at the examples in the documentation. The only action that does not require data is a delete as far as I can remember.

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.