# Elasticsearch Bulk Update API failing due to wrong input

**URL:** <https://discuss.elastic.co/t/elasticsearch-bulk-update-api-failing-due-to-wrong-input/171462>\
**Category:** Elasticsearch\
**Created:** [March 8, 2019, 9:20am UTC](https://discuss.elastic.co/t/elasticsearch-bulk-update-api-failing-due-to-wrong-input/171462 "2019-03-08T09:20:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![prasad.ram1431](https://avatars.discourse-cdn.com/v4/letter/p/c89c15/32.png) [@prasad.ram1431](https://discuss.elastic.co/u/prasad.ram1431)\
**Post date:** [March 8, 2019, 9:20am UTC](https://discuss.elastic.co/t/elasticsearch-bulk-update-api-failing-due-to-wrong-input/171462/1 "2019-03-08T09:20:56Z")

</div>

Hi All,

Could you please let me if the below scenario is whether expected behaviour.

Scenario:

```
POST _bulk
{ "update" : { "_index" : "test", "_type" : "_doc", "_id" : "2" } }
{ "doc" : {"field2" : "value2"} }
{ "update" : { "_index" : "test", "_type" : "_doc", "_id" : "3" } }
{ "doc" : {"field2" : "value2"} }
{ "update" : { "_index" : "test", "_type" : "_doc", "_id" : "4" } }
{ "doc" : {"field2" : "value2"} ,}

```

When I am trying to execute above api, complete process is failing.  
I was expecting like, only updating of doc with Id: 4 should be failed.  
But its failing for all the other docs even.

Could someone provide some inputs on this please.

Thanks,  
Ram Prasad G

---

<div class="post-metadata">

**Author:** ![prasad.ram1431](https://avatars.discourse-cdn.com/v4/letter/p/c89c15/32.png) [@prasad.ram1431](https://discuss.elastic.co/u/prasad.ram1431)\
**Post date:** [March 8, 2019, 10:23am UTC](https://discuss.elastic.co/t/elasticsearch-bulk-update-api-failing-due-to-wrong-input/171462/2 "2019-03-08T10:23:14Z")

</div>

Hi David,

thank you for updating format of my post, I tried while framing but it didn't worked.  
Any inputs on my question will be very helpful.

Thanks,  
Ram Prasad G

---

<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:** [March 8, 2019, 10:40am UTC](https://discuss.elastic.co/t/elasticsearch-bulk-update-api-failing-due-to-wrong-input/171462/3 "2019-03-08T10:40:44Z")

</div>

When you use the Bulk API, you are using a `application/x-ndjson` content type. You must conform with that specification.

The request is malformed so it can not be read by Elasticsearch which rejects the whole with:

```auto
$ curl -s -H "Content-Type: application/x-ndjson" -XPOST localhost:9200/_bulk --data-binary "@test.bulk"; echo

```

```auto
{"error":{"root_cause":[{"type":"json_parse_exception","reason":"Unexpected character ('}' (code 125)): was expecting double-quote to start field name\n at [Source: org.elasticsearch.transport.netty4.ByteBufStreamInput@c42c633; line: 1, column: 35]"}],"type":"json_parse_exception","reason":"Unexpected character ('}' (code 125)): was expecting double-quote to start field name\n at [Source: org.elasticsearch.transport.netty4.ByteBufStreamInput@c42c633; line: 1, column: 35]"},"status":500}

```

You need to respect the specification. There's no workaround this AFAIK.

---

<div class="post-metadata">

**Author:** ![prasad.ram1431](https://avatars.discourse-cdn.com/v4/letter/p/c89c15/32.png) [@prasad.ram1431](https://discuss.elastic.co/u/prasad.ram1431)\
**Post date:** [March 8, 2019, 12:49pm UTC](https://discuss.elastic.co/t/elasticsearch-bulk-update-api-failing-due-to-wrong-input/171462/4 "2019-03-08T12:49:18Z")

</div>

Thank you David. It helped me.

---

<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:** [April 5, 2019, 1:04pm UTC](https://discuss.elastic.co/t/elasticsearch-bulk-update-api-failing-due-to-wrong-input/171462/5 "2019-04-05T13:04:04Z")

</div>

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