# Problem using bulk api with -d flag

**URL:** https://discuss.elastic.co/t/problem-using-bulk-api-with-d-flag/9930
**Category:** Elasticsearch
**Created:** [December 4, 2012, 11:06am UTC](https://discuss.elastic.co/t/problem-using-bulk-api-with-d-flag/9930 "2012-12-04T11:06:26Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![sylvain](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sylvain/32/2476_2.png) [@sylvain](https://discuss.elastic.co/u/sylvain)
#### Post date: [December 4, 2012, 11:06am UTC](https://discuss.elastic.co/t/problem-using-bulk-api-with-d-flag/9930/1 "2012-12-04T11:06:26Z")

</div>

Hi,

if someone could indicate what is wrong in the following request, that  
would be nice.

$ curl -XPOST localhost:9200/\_bulk -d '{ "delete" : { "\_index" : "test",  
"\_type" : "type1", "\_id" : "5"}}'

The output of the above request is:

{"error":"ActionRequestValidationException[Validation Failed: 1: no  
requests added;]","status":500}

When passing the request input into a file it works fine, as shown below ...

$ curl -XPOST localhost:9200/\_bulk --data-binary @delete\_req; echo  
{"took":0,"items":[{"delete":{"\_index":"test","\_type":"type1","\_id":"5","\_version":3,"ok":true}}]}

where the file delete\_req contains the same input that is used with the -d  
flag approach.

$ cat delete\_req  
{ "delete" : { "\_index" : "test", "\_type" : "type1", "\_id" : "5"}}

So, I guess I am overlooking a detail, and I would be grateful if someone  
could point out the proper way to use the -d flag approach.

Thanks,  
Sylvain

--

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [December 4, 2012, 11:12am UTC](https://discuss.elastic.co/t/problem-using-bulk-api-with-d-flag/9930/2 "2012-12-04T11:12:42Z")

</div>

Hi Sylvain.

Have a look at [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/bulk.html)

NOTE: the final line of data must end with a newline character \n.

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.

Could it be your concern?

David.

Le 4 décembre 2012 à 12:06, sylvain [sylvain.bellemare@ezeep.com](mailto:sylvain.bellemare@ezeep.com) a écrit :

> Hi,
> 
> if someone could indicate what is wrong in the following request, that would  
> be nice.
> 
> $ curl -XPOST localhost:9200/\_bulk -d '{ "delete" : { "\_index" : "test",  
> "\_type" : "type1", "\_id" : "5"}}'
> 
> The output of the above request is:
> 
> {"error":"ActionRequestValidationException[Validation Failed: 1: no requests  
> added;]","status":500}
> 
> When passing the request input into a file it works fine, as shown below ...
> 
> $ curl -XPOST localhost:9200/\_bulk --data-binary @delete\_req; echo
> 
> {"took":0,"items":[{"delete":{"\_index":"test","\_type":"type1","\_id":"5","\_version":3,"ok":true}}]}
> 
> where the file delete\_req contains the same input that is used with the -d  
> flag approach.
> 
> $ cat delete\_req  
> { "delete" : { "\_index" : "test", "\_type" : "type1", "\_id" : "5"}}
> 
> So, I guess I am overlooking a detail, and I would be grateful if someone  
> could point out the proper way to use the -d flag approach.
> 
> Thanks,  
> Sylvain
> 
> --

--  
David Pilato  
[http://www.scrutmydocs.org/](http://www.scrutmydocs.org/)  
[http://dev.david.pilato.fr/](http://dev.david.pilato.fr/)  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

--

---

<div class="post-metadata">

### Author: ![sylvain](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sylvain/32/2476_2.png) [@sylvain](https://discuss.elastic.co/u/sylvain)
#### Post date: [December 4, 2012, 12:09pm UTC](https://discuss.elastic.co/t/problem-using-bulk-api-with-d-flag/9930/3 "2012-12-04T12:09:11Z")

</div>

Thanks David for replying.

I tried with the end of line character as well, but it still does not work.

$ curl -XPOST localhost:9200/\_bulk -d '{ "delete" : { "\_index" : "test",  
"\_type" : "type1", "\_id" : "5"}}\n'  
{"error":"ActionRequestValidationException[Validation Failed: 1: no  
requests added;]","status":500}

I am actually (trying) to follow the documentation  
([Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/bulk.html)), and using a  
text file as input does work fine (with the --data-binary flag). What I  
wish to know is how to make the request with the -d flag, without a text  
file, by just passing the input as a string ...

On Tuesday, 4 December 2012 12:12:42 UTC+1, David Pilato wrote:

> Hi Sylvain.
> 
> Have a look at [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/bulk.html)
> 
> _NOTE_: the final line of data must end with a newline character \n.  
> 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.
> 
> Could it be your concern?
> 
> David.
> 
> Le 4 décembre 2012 à 12:06, sylvain \<[sylvain....@ezeep.com](mailto:sylvain....@ezeep.com) \<javascript:\>\>  
> a écrit :
> 
> Hi,
> 
> if someone could indicate what is wrong in the following request, that  
> would be nice.
> 
> $ curl -XPOST localhost:9200/\_bulk -d '{ "delete" : { "\_index" :  
> "test", "\_type" : "type1", "\_id" : "5"}}'
> 
> The output of the above request is:
> 
> {"error":"ActionRequestValidationException[Validation Failed: 1: no  
> requests added;]","status":500}
> 
> When passing the request input into a file it works fine, as shown below  
> ...
> 
> $ curl -XPOST localhost:9200/\_bulk --data-binary @delete\_req; echo  
> {"took":0,"items":[{"delete":{"\_index":"test","\_type":"type1","\_id":"5","\_version":3,"ok":true}}]}
> 
> where the file delete\_req contains the same input that is used with the  
> -d flag approach.
> 
> $ cat delete\_req  
> { "delete" : { "\_index" : "test", "\_type" : "type1", "\_id" : "5"}}
> 
> So, I guess I am overlooking a detail, and I would be grateful if someone  
> could point out the proper way to use the -d flag approach.
> 
> Thanks,  
> Sylvain
> 
> --
> 
> --  
> David Pilato  
> [http://www.scrutmydocs.org/](http://www.scrutmydocs.org/)  
> [http://dev.david.pilato.fr/](http://dev.david.pilato.fr/)  
> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

--

---

<div class="post-metadata">

### Author: ![sylvain](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sylvain/32/2476_2.png) [@sylvain](https://discuss.elastic.co/u/sylvain)
#### Post date: [December 4, 2012, 6:21pm UTC](https://discuss.elastic.co/t/problem-using-bulk-api-with-d-flag/9930/4 "2012-12-04T18:21:18Z")

</div>

The following works ...

$ curl -XPOST localhost:9200/\_bulk -d '{"delete": {"\_index": "test",  
"\_type": "type1", "\_id": "1"}

> }'

On Tuesday, 4 December 2012 13:09:11 UTC+1, sylvain wrote:

> Thanks David for replying.
> 
> I tried with the end of line character as well, but it still does not work.
> 
> $ curl -XPOST localhost:9200/\_bulk -d '{ "delete" : { "\_index" : "test",  
> "\_type" : "type1", "\_id" : "5"}}\n'  
> {"error":"ActionRequestValidationException[Validation Failed: 1: no  
> requests added;]","status":500}
> 
> I am actually (trying) to follow the documentation (  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/bulk.html)), and using a  
> text file as input does work fine (with the --data-binary flag). What I  
> wish to know is how to make the request with the -d flag, without a text  
> file, by just passing the input as a string ...
> 
> On Tuesday, 4 December 2012 12:12:42 UTC+1, David Pilato wrote:
> 
> > Hi Sylvain.
> > 
> > Have a look at  
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/bulk.html)
> > 
> > _NOTE_: the final line of data must end with a newline character \n.  
> > 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.
> > 
> > Could it be your concern?
> > 
> > David.
> > 
> > Le 4 décembre 2012 à 12:06, sylvain [sylvain....@ezeep.com](mailto:sylvain....@ezeep.com) a écrit :
> > 
> > Hi,
> > 
> > if someone could indicate what is wrong in the following request, that  
> > would be nice.
> > 
> > $ curl -XPOST localhost:9200/\_bulk -d '{ "delete" : { "\_index" :  
> > "test", "\_type" : "type1", "\_id" : "5"}}'
> > 
> > The output of the above request is:
> > 
> > {"error":"ActionRequestValidationException[Validation Failed: 1: no  
> > requests added;]","status":500}
> > 
> > When passing the request input into a file it works fine, as shown below  
> > ...
> > 
> > $ curl -XPOST localhost:9200/\_bulk --data-binary @delete\_req; echo  
> > {"took":0,"items":[{"delete":{"\_index":"test","\_type":"type1","\_id":"5","\_version":3,"ok":true}}]}
> > 
> > where the file delete\_req contains the same input that is used with the  
> > -d flag approach.
> > 
> > $ cat delete\_req  
> > { "delete" : { "\_index" : "test", "\_type" : "type1", "\_id" : "5"}}
> > 
> > So, I guess I am overlooking a detail, and I would be grateful if  
> > someone could point out the proper way to use the -d flag approach.
> > 
> > Thanks,  
> > Sylvain
> > 
> > --
> > 
> > --  
> > David Pilato  
> > [http://www.scrutmydocs.org/](http://www.scrutmydocs.org/)  
> > [http://dev.david.pilato.fr/](http://dev.david.pilato.fr/)  
> > Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

--

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [December 4, 2012, 6:35pm UTC](https://discuss.elastic.co/t/problem-using-bulk-api-with-d-flag/9930/5 "2012-12-04T18:35:07Z")

</div>

But why do you use bulk for only one Delete action?

--  
David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 4 déc. 2012 à 19:21, sylvain [sylvain.bellemare@ezeep.com](mailto:sylvain.bellemare@ezeep.com) a écrit :

> The following works ...
> 
> $ curl -XPOST localhost:9200/\_bulk -d '{"delete": {"\_index": "test", "\_type": "type1", "\_id": "1"}
> 
> > }'
> 
> On Tuesday, 4 December 2012 13:09:11 UTC+1, sylvain wrote:  
> Thanks David for replying.
> 
> I tried with the end of line character as well, but it still does not work.
> 
> $ curl -XPOST localhost:9200/\_bulk -d '{ "delete" : { "\_index" : "test", "\_type" : "type1", "\_id" : "5"}}\n'  
> {"error":"ActionRequestValidationException[Validation Failed: 1: no requests added;]","status":500}
> 
> I am actually (trying) to follow the documentation ([Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/bulk.html)), and using a text file as input does work fine (with the --data-binary flag). What I wish to know is how to make the request with the -d flag, without a text file, by just passing the input as a string ...
> 
> On Tuesday, 4 December 2012 12:12:42 UTC+1, David Pilato wrote:  
> Hi Sylvain.
> 
> Have a look at [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/bulk.html)
> 
> NOTE: the final line of data must end with a newline character \n.
> 
> 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.
> 
> Could it be your concern?
> 
> David.
> 
> Le 4 décembre 2012 à 12:06, sylvain [sylvain....@ezeep.com](mailto:sylvain....@ezeep.com) a écrit :
> 
> > Hi,
> > 
> > if someone could indicate what is wrong in the following request, that would be nice.
> > 
> > $ curl -XPOST localhost:9200/\_bulk -d '{ "delete" : { "\_index" : "test", "\_type" : "type1", "\_id" : "5"}}'
> > 
> > The output of the above request is:
> > 
> > {"error":"ActionRequestValidationException[Validation Failed: 1: no requests added;]","status":500}
> > 
> > When passing the request input into a file it works fine, as shown below ...
> > 
> > $ curl -XPOST localhost:9200/\_bulk --data-binary @delete\_req; echo  
> > {"took":0,"items":[{"delete":{"\_index":"test","\_type":"type1","\_id":"5","\_version":3,"ok":true}}]}
> > 
> > where the file delete\_req contains the same input that is used with the -d flag approach.
> > 
> > $ cat delete\_req  
> > { "delete" : { "\_index" : "test", "\_type" : "type1", "\_id" : "5"}}
> > 
> > So, I guess I am overlooking a detail, and I would be grateful if someone could point out the proper way to use the -d flag approach.
> > 
> > Thanks,  
> > Sylvain
> > 
> > --
> 
> ## -- David Pilato [http://www.scrutmydocs.org/](http://www.scrutmydocs.org/) [http://dev.david.pilato.fr/](http://dev.david.pilato.fr/) Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

--

---

<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 6, 2017, 3:01am UTC](https://discuss.elastic.co/t/problem-using-bulk-api-with-d-flag/9930/6 "2017-07-06T03:01:31Z")

</div>


