# Node - Bulk indexing not working - Content-Type header \[application/x-ldjson\] is not supported

**URL:** <https://discuss.elastic.co/t/node-bulk-indexing-not-working-content-type-header-application-x-ldjson-is-not-supported/114944>\
**Category:** Elasticsearch\
**Created:** [January 10, 2018, 7:43pm UTC](https://discuss.elastic.co/t/node-bulk-indexing-not-working-content-type-header-application-x-ldjson-is-not-supported/114944 "2018-01-10T19:43:14Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![venkkiram](https://avatars.discourse-cdn.com/v4/letter/v/77aa72/32.png) [@venkkiram](https://discuss.elastic.co/u/venkkiram)\
**Post date:** [January 10, 2018, 7:43pm UTC](https://discuss.elastic.co/t/node-bulk-indexing-not-working-content-type-header-application-x-ldjson-is-not-supported/114944/1 "2018-01-10T19:43:14Z")

</div>

Am new and exploring elasticsearch integration with node and trying to execute the following example in my windows.

> **[GitHub - sitepoint-editors/node-elasticsearch-tutorial: Examples for setting...](https://github.com/sitepoint-editors/node-elasticsearch-tutorial)**
>
> Examples for setting up and using elasticsearch in Node.js - GitHub - sitepoint-editors/node-elasticsearch-tutorial: Examples for setting up and using elasticsearch in Node.js

while trying to import the data from data.json, the 'node index.js' is able to only parse the items in data file but not indexing those items into my elasticsearch instance.

I am not getting the log statement "Successfully indexed 1000 out of 1000 items" printed.

> esClient.bulk({body: bulkBody})  
> .then(response =\> {  
> let errorCount = 0;  
> response.items.forEach(item =\> {  
> if (item.index && item.index.error) {  
> console.log(++errorCount, item.index.error);  
> }  
> });  
> console.log(`Successfully indexed ${data.length - errorCount} out of ${data.length} items`);  
> })  
> .catch(console.err);  
> };

Any idea what step is missing here?

**java** version 1.8.0\_121  
**elasticsearch** version 6.1.1  
**node** version v8.5.0

--  
Thanks.  
Venkkiram

---

<div class="post-metadata">

**Author:** ![venkkiram](https://avatars.discourse-cdn.com/v4/letter/v/77aa72/32.png) [@venkkiram](https://discuss.elastic.co/u/venkkiram)\
**Post date:** [January 12, 2018, 4:10pm UTC](https://discuss.elastic.co/t/node-bulk-indexing-not-working-content-type-header-application-x-ldjson-is-not-supported/114944/2 "2018-01-12T16:10:15Z")

</div>

By enabling the trace, I now see the following as the root cause.

**"error": "Content-Type header [application/x-ldjson] is not supported",**  
\*\* "status": 406\*\*

This happens in bulk indexing while index.js parsing the items from data.json file and trying to index as a bulk.

I see a change log from elasticsearch says following

_13.0.0 (Apr 24 2017)_  
_bulk and other APIs that send line-delimited JSON bodies now use the Content-Type: application/x-ndjson header #507_

Any idea how to resolve this content type issue in index.js?

Thanks.

---

<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:** [January 12, 2018, 4:21pm UTC](https://discuss.elastic.co/t/node-bulk-indexing-not-working-content-type-header-application-x-ldjson-is-not-supported/114944/3 "2018-01-12T16:21:56Z")

</div>

> 13.0.0 (Apr 24 2017)

Where did you find that please?

---

<div class="post-metadata">

**Author:** ![venkkiram](https://avatars.discourse-cdn.com/v4/letter/v/77aa72/32.png) [@venkkiram](https://discuss.elastic.co/u/venkkiram)\
**Post date:** [January 12, 2018, 4:36pm UTC](https://discuss.elastic.co/t/node-bulk-indexing-not-working-content-type-header-application-x-ldjson-is-not-supported/114944/4 "2018-01-12T16:36:56Z")

</div>

the following link describes the changelog content I shared,

[https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/changelog.html](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/changelog.html)

_13.0.0 (Apr 24 2017)_  
_bulk and other APIs that send line-delimited JSON bodies now use the Content-Type: application/x-ndjson header #507_

---

<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:** [January 12, 2018, 6:03pm UTC](https://discuss.elastic.co/t/node-bulk-indexing-not-working-content-type-header-application-x-ldjson-is-not-supported/114944/5 "2018-01-12T18:03:34Z")

</div>

Thanks. As I wrote in

> <https://github.com/elastic/elasticsearch/issues/28199>

I think this should be reported in [https://github.com/elastic/elasticsearch-js](https://github.com/elastic/elasticsearch-js) instead. But make sure first that you are upgrading to the latest version of the JS client.

---

<div class="post-metadata">

**Author:** ![venkkiram](https://avatars.discourse-cdn.com/v4/letter/v/77aa72/32.png) [@venkkiram](https://discuss.elastic.co/u/venkkiram)\
**Post date:** [January 12, 2018, 9:47pm UTC](https://discuss.elastic.co/t/node-bulk-indexing-not-working-content-type-header-application-x-ldjson-is-not-supported/114944/6 "2018-01-12T21:47:07Z")

</div>

Have upgraded npm and node in local windows. Still same error behaviour as below.

> \<- 406  
> {  
> "error": "Content-Type header [application/x-ldjson] is not supported",  
> "status": 406  
> }

Thanks for your inputs. Will create a query in [GitHub - elastic/elasticsearch-js: Official Elasticsearch client library for Node.js](https://github.com/elastic/elasticsearch-js) too as you suggested.

---

<div class="post-metadata">

**Author:** ![venkkiram](https://avatars.discourse-cdn.com/v4/letter/v/77aa72/32.png) [@venkkiram](https://discuss.elastic.co/u/venkkiram)\
**Post date:** [January 14, 2018, 7:30am UTC](https://discuss.elastic.co/t/node-bulk-indexing-not-working-content-type-header-application-x-ldjson-is-not-supported/114944/7 "2018-01-14T07:30:08Z")

</div>

The old version of elasticsearch.js is sending requests with application/x-ldjson which not supported by newer elasticsearch versions.

This issue got resolved after editing the package.json of node-elasticsearch-tutorial project in my local. The version of elasticsearch.js mentioned as 11.0.1 where as the latest one available is 14.0.0.

This brings me the latest version of elasticsearch.js from "npm install elasticsearch".

I am now able to index successfully using the bulk function.

Thanks.

---

<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:** [January 14, 2018, 8:01am UTC](https://discuss.elastic.co/t/node-bulk-indexing-not-working-content-type-header-application-x-ldjson-is-not-supported/114944/8 "2018-01-14T08:01:15Z")

</div>

That's why I wrote:

> But make sure first that you are upgrading to the latest version of the JS client

---

<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:** [February 11, 2018, 8:01am UTC](https://discuss.elastic.co/t/node-bulk-indexing-not-working-content-type-header-application-x-ldjson-is-not-supported/114944/9 "2018-02-11T08:01:20Z")

</div>

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