Need help with this curl command for bulk uploading

I'm doing this under windows. Here is my curl command:

curl -X POST -H "Content-Type:application/x-ndjson" "http://localhost:9200/myindex/logentry/_bulk?pretty" --data-binary @05312019.txt

I'm getting the following error:
{
"error" : {
"root_cause" : [
{
"type" : "illegal_argument_exception",
"reason" : "Malformed action/metadata line [1], expected START_OBJECT or
END_OBJECT but found [VALUE_STRING]"
}
],
"type" : "illegal_argument_exception",
"reason" : "Malformed action/metadata line [1], expected START_OBJECT or END
_OBJECT but found [VALUE_STRING]"
},
"status" : 400
}

The index myindex already exists.
Any help will be appreciated. It is probably something very simple.

The issue is possibly with the file, it needs to be properly formatted as a bulk request , it can not just take a file with one object per line.

action_and_meta_data\n
optional_source\n
action_and_meta_data\n
optional_source\n
....
action_and_meta_data\n
optional_source\n

Try inserting action and metadata \n before every json.
Thanks!

Actually, I found a site that answered my question.


I added a line {"index" : { } } before each line of actual json data, plus I made sure to have a newline at the end of the file. My curl command that worked looked like:
curl -H "Content-Type:application/x-ndjson" -XPOST "http://localhost:9200/myindex/_bulk?pretty" --data-binary @"05312019.txt"
Thank you for getting back to me. I was beginning to wonder if anyone even reads these posts.

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