# ElasticsearchStatusException\[Unable to parse response body\] \[HTTP/1.1 301 Moved Permanently\]

**URL:** <https://discuss.elastic.co/t/elasticsearchstatusexception-unable-to-parse-response-body-http-1-1-301-moved-permanently/314888>\
**Category:** Elasticsearch\
**Created:** [September 21, 2022, 6:14pm UTC](https://discuss.elastic.co/t/elasticsearchstatusexception-unable-to-parse-response-body-http-1-1-301-moved-permanently/314888 "2022-09-21T18:14:22Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jai\_Tripathi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jai_tripathi/32/64032_2.png) [@Jai\_Tripathi](https://discuss.elastic.co/u/Jai_Tripathi)\
**Post date:** [September 21, 2022, 6:14pm UTC](https://discuss.elastic.co/t/elasticsearchstatusexception-unable-to-parse-response-body-http-1-1-301-moved-permanently/314888/1 "2022-09-21T18:14:22Z")

</div>

Hello Everyone,

Key Points:

1. I am able to get response from Elastic search (deployed on AWS) using postman at my machine.
2. However when I am trying to use elasticsearch API to get the response, I am getting ElasticsearchStatusException[Unable to parse response body].

==========================  
Explanation starts from here :

I am hitting my Elasticsearch (deployed on AWS) using springboot microservice, however getting below error :

\< ElasticsearchStatusException[Unable to parse response body]; nested: ResponseException[method [POST], host [[http://b6vv-eks-kibana.verizon.com](http://b6vv-eks-kibana.verizon.com)], URI [/\_search?rest\_total\_hits\_as\_int=true&typed\_keys=true&ignore\_unavailable=false&expand\_wildcards=open&allow\_no\_indices=true&ignore\_throttled=true&search\_type=query\_then\_fetch&batched\_reduce\_size=512], status line [HTTP/1.1 301 Moved Permanently]

# /\>

Source Code as below :

I am using below source code as my implementation, which is copied from Elasticsearch API ([Search API | Java REST Client [7.17] | Elastic](https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/java-rest-high-search.html#java-rest-high-search-sync))

\<  
RestHighLevelClient esClient = new RestHighLevelClient(RestClient.builder(new HttpHost("my-elastic-search-host-name")));  
SearchRequest searchRequest = new SearchRequest();  
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();  
searchSourceBuilder.query(QueryBuilders.matchAllQuery());  
searchRequest.source(searchSourceBuilder);  
SearchResponse searchResponse = esClient.search(searchRequest, RequestOptions.DEFAULT);  
/\>

==================================  
Followed elastic community discussion as below :

I checked these link in elastic discussion and did not found helpful.

1. [ElasticsearchStatusException[Unable to parse response body]; nested: ResponseException[method [POST] - #2 by TimV](https://discuss.elastic.co/t/elasticsearchstatusexception-unable-to-parse-response-body-nested-responseexception-method-post/276321/2)

2. [org.elasticsearch.ElasticsearchStatusException: Unable to parse response body](https://discuss.elastic.co/t/org-elasticsearch-elasticsearchstatusexception-unable-to-parse-response-body/291075)

Please suggest, as all the related help in community is not answered with any user.

---

<div class="post-metadata">

**Author:** ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)\
**Post date:** [September 21, 2022, 7:40pm UTC](https://discuss.elastic.co/t/elasticsearchstatusexception-unable-to-parse-response-body-http-1-1-301-moved-permanently/314888/2 "2022-09-21T19:40:59Z")

</div>

> [@Jai\_Tripathi](#):
>
> status line [HTTP/1.1 301 Moved Permanently]

Elasticsearch never responds with status code 301, so it seems the problem is that you're talking to something other than Elasticsearch.

---

<div class="post-metadata">

**Author:** ![Jai\_Tripathi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jai_tripathi/32/64032_2.png) [@Jai\_Tripathi](https://discuss.elastic.co/u/Jai_Tripathi)\
**Post date:** [September 21, 2022, 7:46pm UTC](https://discuss.elastic.co/t/elasticsearchstatusexception-unable-to-parse-response-body-http-1-1-301-moved-permanently/314888/3 "2022-09-21T19:46:52Z")

</div>

> [@Jai\_Tripathi](#):
>
> esClient

Thank you David for quick turn around, however my esClient shows it is pointing to my elastic hostname.  
I am able to use Elasticsearch with the same hostname.

For reference I am able to get all the indices from my Elasticsearch using the same host name pointing to same esClient.  
Please find reference as below :

\<  
GetIndexRequest indexRequest = new GetIndexRequest("\*");  
GetIndexResponse response = esClient.indices().get(indexRequest, RequestOptions.DEFAULT);  
/\>

---

<div class="post-metadata">

**Author:** ![Jai\_Tripathi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jai_tripathi/32/64032_2.png) [@Jai\_Tripathi](https://discuss.elastic.co/u/Jai_Tripathi)\
**Post date:** [September 21, 2022, 8:13pm UTC](https://discuss.elastic.co/t/elasticsearchstatusexception-unable-to-parse-response-body-http-1-1-301-moved-permanently/314888/4 "2022-09-21T20:13:59Z")

</div>

> [@Jai\_Tripathi](#):
>
> RestHighLevelClient esClient = new RestHighLevelClient(RestClient.builder(new HttpHost("my-elastic-search-host-name")));

This issue got fixed using below changes :

\<  
RestHighLevelClient esClient = new RestHighLevelClient(RestClient.builder(new HttpHost("my-elastic-search-host-name", port, "https")));  
/\>

---

<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:** [October 19, 2022, 8:14pm UTC](https://discuss.elastic.co/t/elasticsearchstatusexception-unable-to-parse-response-body-http-1-1-301-moved-permanently/314888/5 "2022-10-19T20:14:22Z")

</div>

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