# Unable to update in bulk

**URL:** <https://discuss.elastic.co/t/unable-to-update-in-bulk/105685>\
**Category:** Elasticsearch\
**Created:** [October 29, 2017, 10:47pm UTC](https://discuss.elastic.co/t/unable-to-update-in-bulk/105685 "2017-10-29T22:47:10Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aisha1990](https://avatars.discourse-cdn.com/v4/letter/a/b2d939/32.png) [@Aisha1990](https://discuss.elastic.co/u/Aisha1990)\
**Post date:** [October 29, 2017, 10:47pm UTC](https://discuss.elastic.co/t/unable-to-update-in-bulk/105685/1 "2017-10-29T22:47:10Z")

</div>

curl -X POST -d "{"index":{"\_index":"products","type":"shoes","\_id":"3"}}{"name":"Puma","size":"9","color":"black"}\n{"index":{"\_index":"products","\_type":"shoes","\_id":"4"}}{"name":"New Balance","size":"8","color":"black"}" -X POST "[http://localhost:9200/\_bulk?pretty](http://localhost:9200/_bulk?pretty)"  
{  
"error" : {  
"root\_cause" : [  
{  
"type" : "action\_request\_validation\_exception",  
"reason" : "Validation Failed: 1: no requests added;"  
}  
],  
"type" : "action\_request\_validation\_exception",  
"reason" : "Validation Failed: 1: no requests added;"  
},  
"status" : 400  
}

Read that bulk must have entries in new line hence, tried \n however, still getting the error. Kindly advise.

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [October 29, 2017, 11:18pm UTC](https://discuss.elastic.co/t/unable-to-update-in-bulk/105685/2 "2017-10-29T23:18:43Z")

</div>

The first line is missing `_` in the `_type` parameter, you need to use real new lines instead of `\n` characters and as it is outlined in on [this documentation page](https://www.elastic.co/guide/en/elasticsearch/reference/5.6/docs-bulk.html)

> If you’re providing text file input to curl, you **must** use the `--data-binary` flag instead of plain `-d`. The latter doesn’t preserve newlines.

You might also find is easier to store bulk requests in a separate file, or use Kibana console to work with elasticsearch.

---

<div class="post-metadata">

**Author:** ![Aisha1990](https://avatars.discourse-cdn.com/v4/letter/a/b2d939/32.png) [@Aisha1990](https://discuss.elastic.co/u/Aisha1990)\
**Post date:** [October 29, 2017, 11:30pm UTC](https://discuss.elastic.co/t/unable-to-update-in-bulk/105685/3 "2017-10-29T23:30:49Z")

</div>

Hi Igor,

You are correct. Thank you for pointing that out. I had missed \_ for type in the first line. Corrected the command however, still getting the same error -

curl -X POST --data-binary "{"index":{"\_index":"products","\_type":"shoes","\_id":"3"}}{"name":"Puma","size":"9","color":"black"},{"index":{"\_index":"products","\_type":"shoes","\_id":"4"}}{"name":"New Balance","size":"8","color":"black"}" -H "Content-type: application/json" -X POST "[http://localhost:9200/\_bulk?pretty](http://localhost:9200/_bulk?pretty)"

{  
"error" : {  
"root\_cause" : [  
{  
"type" : "action\_request\_validation\_exception",  
"reason" : "Validation Failed: 1: no requests added;"  
}  
],  
"type" : "action\_request\_validation\_exception",  
"reason" : "Validation Failed: 1: no requests added;"  
},  
"status" : 400  
}

What did this error mean? Request your advise.

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [October 29, 2017, 11:42pm UTC](https://discuss.elastic.co/t/unable-to-update-in-bulk/105685/4 "2017-10-29T23:42:36Z")

</div>

Please also check the **NOTE** on the same doc page, you are missing new lines between commands and after the last command.

```auto
curl -X POST --data-binary '{"index":{"_index":"products","_type":"shoes","_id":"3"}}
{"name":"Puma","size":"9","color":"black"}
{"index":{"_index":"products","_type":"shoes","_id":"4"}}
{"name":"New Balance","size":"8","color":"black"}
' -H "Content-type: application/json" -X POST "http://localhost:9200/_bulk?pretty"

```

---

<div class="post-metadata">

**Author:** ![Aisha1990](https://avatars.discourse-cdn.com/v4/letter/a/b2d939/32.png) [@Aisha1990](https://discuss.elastic.co/u/Aisha1990)\
**Post date:** [October 30, 2017, 12:09am UTC](https://discuss.elastic.co/t/unable-to-update-in-bulk/105685/5 "2017-10-30T00:09:28Z")

</div>

You are correct. I am having a trouble understanding how to introduce a newline character when I type this command from command prompt of the Windows machine -

curl -X POST --data-binary "{"index":{"\_index":"products","\_type":"shoes","\_id":"3"}},{"name":"Puma","size":"9","color":"black"}, (\<---- I need a newline character here)  
{"index":{"\_index":"products","\_type":"shoes","\_id":"4"}},(\<----- I need a newline character here)  
{"name":"New Balance","size":"8","color":"black"}" -H "Content-type: application/x-ndjson" -X POST "[http://localhost:9200/\_bulk?pretty](http://localhost:9200/_bulk?pretty)"

I tried even using "x-ndjson" as specified in the document but it did not work. Kindly help how do I do it?

---

<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:** [November 27, 2017, 12:10am UTC](https://discuss.elastic.co/t/unable-to-update-in-bulk/105685/6 "2017-11-27T00:10:05Z")

</div>

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