# RestHighLevelClient - Unable to parse response body

**URL:** <https://discuss.elastic.co/t/resthighlevelclient-unable-to-parse-response-body/240809>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [July 11, 2020, 7:20pm UTC](https://discuss.elastic.co/t/resthighlevelclient-unable-to-parse-response-body/240809 "2020-07-11T19:20:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![drouinc](https://avatars.discourse-cdn.com/v4/letter/d/f08c70/32.png) [@drouinc](https://discuss.elastic.co/u/drouinc)\
**Post date:** [July 11, 2020, 7:20pm UTC](https://discuss.elastic.co/t/resthighlevelclient-unable-to-parse-response-body/240809/1 "2020-07-11T19:20:08Z")

</div>

I'm new to ES and wiring up my first sample in a Java Spring Boot app. I'm using the pure  
RestHighLevelClient approach but seem to keep getting a Unable to parse response body message when I call the client.

I'm a bit stuck on how to populate SearchResponse, any thoughts on how to troubleshoot?

```auto
// Config class

   @Bean
    public RestHighLevelClient client() {
        return new RestHighLevelClient(RestClient.builder(new HttpHost(hostUrl, port, scheme)));
    }
	
// Proxy class

    public List<ResidentModel> getInitialSample() {

        SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
        searchSourceBuilder.query(QueryBuilders.termQuery("first_name", "john"));
        searchSourceBuilder.from(0);
        searchSourceBuilder.size(5);
        SearchRequest searchRequest = new SearchRequest(new String[] {"myresidents"}, searchSourceBuilder);

        SearchResponse searchResponse = null;
        try{
            searchResponse = client.search(searchRequest, RequestOptions.DEFAULT);
        }catch (ElasticsearchException ex){
            DebugFailedQuery(ex);
        }
        if(searchResponse!=null){
            SearchHits hits = searchResponse.getHits();
        }
        return null; // still need to deserialize the response.
    }

```

---

<div class="post-metadata">

**Author:** ![drouinc](https://avatars.discourse-cdn.com/v4/letter/d/f08c70/32.png) [@drouinc](https://discuss.elastic.co/u/drouinc)\
**Post date:** [July 14, 2020, 12:04pm UTC](https://discuss.elastic.co/t/resthighlevelclient-unable-to-parse-response-body/240809/2 "2020-07-14T12:04:46Z")

</div>

I figured it out. Elastic was installed on a Kubernetes cluster I was trying to hit [elasticsearch.mycompany.com:80](http://elasticsearch.mycompany.com:80) and the NginX ingress controller was not configured with SSL but had the following flag set trying to redirect access.

```auto
nginx.ingress.kubernetes.io/force-ssl-redirect: "true"

```

So if you get a "Unable to parse response body" message (mine was from the request not the response) and if you spot a " 308 Permanent Redirect" in the stack trace, the issues could be on the server hosting elastic.

---

<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:** [August 11, 2020, 12:04pm UTC](https://discuss.elastic.co/t/resthighlevelclient-unable-to-parse-response-body/240809/3 "2020-08-11T12:04:56Z")

</div>

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