# Cannot read data from Elastic 6.0: "error":"Content-Type header \[text/plain\] is not supported","status":406

**URL:** <https://discuss.elastic.co/t/cannot-read-data-from-elastic-6-0-error-content-type-header-text-plain-is-not-supported-status-406/116366>\
**Category:** Elasticsearch\
**Created:** [January 21, 2018, 3:25am UTC](https://discuss.elastic.co/t/cannot-read-data-from-elastic-6-0-error-content-type-header-text-plain-is-not-supported-status-406/116366 "2018-01-21T03:25:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![betty](https://avatars.discourse-cdn.com/v4/letter/b/0ea827/32.png) [@betty](https://discuss.elastic.co/u/betty)\
**Post date:** [January 21, 2018, 3:25am UTC](https://discuss.elastic.co/t/cannot-read-data-from-elastic-6-0-error-content-type-header-text-plain-is-not-supported-status-406/116366/1 "2018-01-21T03:25:08Z")

</div>

Hi experts,

I create a client in java and want to get the query results from index but got the 406 error:  
"Content-Type header [text/plain] is not supported","status":406.

Java platform: 1.6  
ES version: 6.0

Below is the code snippet:

```
  Client clientInstance = Client.create();
  clientInstance.addFilter(new HTTPBasicAuthFilter("", "")); // No Auth in sample RI

  WebResource webResource =
      clientInstance.resource("http://hostname:9200/indexname/_search"); 
  ClientResponse response =
      webResource.entity(aggDsl).accept("application/json").get(ClientResponse.class);

  String resultEntity = response.getEntity(String.class);

```

I use the DSL in kibana and can get the correct query results. But it did not get the correct response in java and throw 406 error.

How can I fix this issue? Thanks veru much!

---

<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 21, 2018, 7:25am UTC](https://discuss.elastic.co/t/cannot-read-data-from-elastic-6-0-error-content-type-header-text-plain-is-not-supported-status-406/116366/2 "2018-01-21T07:25:48Z")

</div>

You need to provide the Content-Type.

---

<div class="post-metadata">

**Author:** ![val](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/val/32/138203_2.png) [@val](https://discuss.elastic.co/u/val)\
**Post date:** [January 21, 2018, 7:36am UTC](https://discuss.elastic.co/t/cannot-read-data-from-elastic-6-0-error-content-type-header-text-plain-is-not-supported-status-406/116366/4 "2018-01-21T07:36:01Z")

</div>

I didn't see it was cross-posted, but I answered here

> <https://stackoverflow.com/questions/48364350/cannot-get-data-from-elastic-6-0-error-content-type-header-text-plain-is-n/48364371#48364371>

---

<div class="post-metadata">

**Author:** ![betty](https://avatars.discourse-cdn.com/v4/letter/b/0ea827/32.png) [@betty](https://discuss.elastic.co/u/betty)\
**Post date:** [January 22, 2018, 1:35am UTC](https://discuss.elastic.co/t/cannot-read-data-from-elastic-6-0-error-content-type-header-text-plain-is-not-supported-status-406/116366/5 "2018-01-22T01:35:07Z")

</div>

Yes, it solves this issue and thanks.

---

<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 19, 2018, 1:35am UTC](https://discuss.elastic.co/t/cannot-read-data-from-elastic-6-0-error-content-type-header-text-plain-is-not-supported-status-406/116366/6 "2018-02-19T01:35:19Z")

</div>

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