# "The bulk request must be terminated by a newline \[\\\\n\]"

**URL:** <https://discuss.elastic.co/t/the-bulk-request-must-be-terminated-by-a-newline-n/179081>\
**Category:** Elasticsearch\
**Created:** [April 30, 2019, 12:44pm UTC](https://discuss.elastic.co/t/the-bulk-request-must-be-terminated-by-a-newline-n/179081 "2019-04-30T12:44:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Miao](https://avatars.discourse-cdn.com/v4/letter/m/8baadc/32.png) [@Miao](https://discuss.elastic.co/u/Miao)\
**Post date:** [April 30, 2019, 12:44pm UTC](https://discuss.elastic.co/t/the-bulk-request-must-be-terminated-by-a-newline-n/179081/1 "2019-04-30T12:44:16Z")

</div>

I have found similar questions both here as well as on StackOverflow, but unfortunately none of the answers helped.

I am currently using ElasticSearch 7.0.

I want to make a bulk request to my ElasticSearch server. My JSON file contains information that looks something like this:

```auto
{ "index": { "_index": "website", "_id": "link1" }}
{ "label": "Link1" }

```

Each line is terminated by an `LF` line break, and there is also an additional `LF` line break at the end of the document.

In C#, here is how I make a POST request for my bulk data:

`HttpResponseMessage response = await httpClient.PostAsJsonAsync($"http://127.0.0.1:9200/website/_bulk", jsonDocumentContents);`

And yet I keep seeing this error message:

`{"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"The bulk request must be terminated by a newline [\\n]"}],"type":"illegal_argument_exception","reason":"The bulk request must be terminated by a newline [\\n]"},"status":400}`

How can I fix this error?

---

<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:** [April 30, 2019, 1:06pm UTC](https://discuss.elastic.co/t/the-bulk-request-must-be-terminated-by-a-newline-n/179081/2 "2019-04-30T13:06:02Z")

</div>

Add a new line at the end of your content.

---

<div class="post-metadata">

**Author:** ![Miao](https://avatars.discourse-cdn.com/v4/letter/m/8baadc/32.png) [@Miao](https://discuss.elastic.co/u/Miao)\
**Post date:** [April 30, 2019, 1:06pm UTC](https://discuss.elastic.co/t/the-bulk-request-must-be-terminated-by-a-newline-n/179081/3 "2019-04-30T13:06:36Z")

</div>

I have done that, but still see the same error.

---

<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:** [April 30, 2019, 4:36pm UTC](https://discuss.elastic.co/t/the-bulk-request-must-be-terminated-by-a-newline-n/179081/4 "2019-04-30T16:36:10Z")

</div>

You probably did it wrongly.  
May be share your file on [gist.github.com](http://gist.github.com) so we can inspect it?

Try with CR-LF

---

<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:** [May 28, 2019, 4:42pm UTC](https://discuss.elastic.co/t/the-bulk-request-must-be-terminated-by-a-newline-n/179081/5 "2019-05-28T16:42:12Z")

</div>

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