# \[Resolved\] 400 Error ResponseException when using example request code for Java REST Client

**URL:** <https://discuss.elastic.co/t/resolved-400-error-responseexception-when-using-example-request-code-for-java-rest-client/98445>\
**Category:** Elasticsearch\
**Created:** [August 26, 2017, 7:58am UTC](https://discuss.elastic.co/t/resolved-400-error-responseexception-when-using-example-request-code-for-java-rest-client/98445 "2017-08-26T07:58:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jaspreet\_Singh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jaspreet_singh/32/58296_2.png) [@Jaspreet\_Singh](https://discuss.elastic.co/u/Jaspreet_Singh)\
**Post date:** [August 26, 2017, 7:58am UTC](https://discuss.elastic.co/t/resolved-400-error-responseexception-when-using-example-request-code-for-java-rest-client/98445/1 "2017-08-26T07:58:04Z")

</div>

Hi,

Im trying to invoke search queries via GET body request.  
While trying to execute the example request code here - [https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/\_example\_requests.html](https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/_example_requests.html)  
Im seeing

```auto
org.elasticsearch.client.ResponseException: GET https://myhost.com/es/_search: HTTP/1.1 400 Error

```

While an invalid query, for example trying to sort by a non existent field, that gives a similar ResponseException 400 error, shows up on elasticsearch logs, the above isnt showing up in logs at all.  
Hence proving difficult to debug too.

Any help would be greatly appreciated.

---

<div class="post-metadata">

**Author:** ![Jaspreet\_Singh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jaspreet_singh/32/58296_2.png) [@Jaspreet\_Singh](https://discuss.elastic.co/u/Jaspreet_Singh)\
**Post date:** [August 26, 2017, 3:10pm UTC](https://discuss.elastic.co/t/resolved-400-error-responseexception-when-using-example-request-code-for-java-rest-client/98445/2 "2017-08-26T15:10:02Z")

</div>

Apparently the gateway did not like GET with body requests and was not letting requests through.  
No wonder I wasnt seeing any error msgs from elasticsearch.  
I tried GET with body by directly connecting to the machine, worked like charm.  
Looks like I will resort to POST with body. This post confirmed the same too - [https://github.com/elastic/elasticsearch-py/issues/281](https://github.com/elastic/elasticsearch-py/issues/281)  
This should be mentioned on the Java REST sample page as a footnote or something. Would have saved me a lot of heart burn.

---

<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:** [September 23, 2017, 3:10pm UTC](https://discuss.elastic.co/t/resolved-400-error-responseexception-when-using-example-request-code-for-java-rest-client/98445/3 "2017-09-23T15:10:17Z")

</div>

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