# Need help with this curl command for bulk uploading

**URL:** <https://discuss.elastic.co/t/need-help-with-this-curl-command-for-bulk-uploading/186074>\
**Category:** Elasticsearch\
**Created:** [June 17, 2019, 1:29pm UTC](https://discuss.elastic.co/t/need-help-with-this-curl-command-for-bulk-uploading/186074 "2019-06-17T13:29:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![KathyTheGreat](https://avatars.discourse-cdn.com/v4/letter/k/65b543/32.png) [@KathyTheGreat](https://discuss.elastic.co/u/KathyTheGreat)\
**Post date:** [June 17, 2019, 1:29pm UTC](https://discuss.elastic.co/t/need-help-with-this-curl-command-for-bulk-uploading/186074/1 "2019-06-17T13:29:37Z")

</div>

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](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.

---

<div class="post-metadata">

**Author:** ![kartikcr](https://avatars.discourse-cdn.com/v4/letter/k/c89c15/32.png) [@kartikcr](https://discuss.elastic.co/u/kartikcr)\
**Post date:** [June 17, 2019, 9:52pm UTC](https://discuss.elastic.co/t/need-help-with-this-curl-command-for-bulk-uploading/186074/2 "2019-06-17T21:52:35Z")

</div>

The issue is possibly with the file, it needs to be properly formatted as a [bulk request](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html), it can not just take a file with one object per line.

```auto
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!

---

<div class="post-metadata">

**Author:** ![KathyTheGreat](https://avatars.discourse-cdn.com/v4/letter/k/65b543/32.png) [@KathyTheGreat](https://discuss.elastic.co/u/KathyTheGreat)\
**Post date:** [June 18, 2019, 1:08am UTC](https://discuss.elastic.co/t/need-help-with-this-curl-command-for-bulk-uploading/186074/3 "2019-06-18T01:08:13Z")

</div>

Actually, I found a site that answered my question.

> **[Create documents from JOSN file using "\_bulk" API of Elasticsearch - Bulk...](http://www.devinline.com/2018/01/bulk-index-document-from-josn-file.html)**
>
> Bulk index document from JOSN file - "\_bulk" API of Elasticsearch

  
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](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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 16, 2019, 1:08am UTC](https://discuss.elastic.co/t/need-help-with-this-curl-command-for-bulk-uploading/186074/4 "2019-07-16T01:08:19Z")

</div>

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