# Headers for the Java REST Client

**URL:** <https://discuss.elastic.co/t/headers-for-the-java-rest-client/107684>\
**Category:** Elasticsearch\
**Created:** [November 15, 2017, 8:21am UTC](https://discuss.elastic.co/t/headers-for-the-java-rest-client/107684 "2017-11-15T08:21:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jettro](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jettro/32/3418_2.png) [@jettro](https://discuss.elastic.co/u/jettro)\
**Post date:** [November 15, 2017, 8:21am UTC](https://discuss.elastic.co/t/headers-for-the-java-rest-client/107684/1 "2017-11-15T08:21:14Z")

</div>

I understand that in elasticsearch 6 the content type header is mandatory. I get a nice exception when omitting it when connecting using the low level rest client.

`{"error":"Content-Type header [text/plain; charset=ISO-8859-1] is not supported","status":406}`

Is there a good reason not to include it by default? I know I can do this myself when creating the client using the default headers, but I would like to understand why this is not the default out of the box as almost all request will need it

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:** [November 15, 2017, 9:52am UTC](https://discuss.elastic.co/t/headers-for-the-java-rest-client/107684/2 "2017-11-15T09:52:25Z")

</div>

> as almost all request will need it

Sometimes if you want to use something like `_bulk` you are probably going to use another content-type than `application/json`. That's probably why.  
Some people also want to provide yaml instead of json.

Note that the High Level client hides all that "complexity".

---

<div class="post-metadata">

**Author:** ![jettro](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jettro/32/3418_2.png) [@jettro](https://discuss.elastic.co/u/jettro)\
**Post date:** [November 15, 2017, 12:48pm UTC](https://discuss.elastic.co/t/headers-for-the-java-rest-client/107684/3 "2017-11-15T12:48:06Z")

</div>

Ah good point, did not thing about those two usecases. Thanks.

I know about the high level client, I use it in projects already. I also like to use the low level client with a custom wrapper sometimes.

---

<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:** [December 13, 2017, 12:48pm UTC](https://discuss.elastic.co/t/headers-for-the-java-rest-client/107684/4 "2017-12-13T12:48:10Z")

</div>

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