# Passing JSON query in GWT

**URL:** <https://discuss.elastic.co/t/passing-json-query-in-gwt/66315>\
**Category:** Elasticsearch\
**Created:** [November 17, 2016, 12:05am UTC](https://discuss.elastic.co/t/passing-json-query-in-gwt/66315 "2016-11-17T00:05:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Velusamy\_Velu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/velusamy_velu/32/72364_2.png) [@Velusamy\_Velu](https://discuss.elastic.co/u/Velusamy_Velu)\
**Post date:** [November 17, 2016, 12:05am UTC](https://discuss.elastic.co/t/passing-json-query-in-gwt/66315/1 "2016-11-17T00:05:52Z")

</div>

I'm trying to run the below query from a Java RESTful client -

[http://localhost:9200/catalog/drawings/\_search](http://localhost:9200/catalog/drawings/_search)? -d '{"query":{"bool":{"must":{"term":{"hashCode":1049279250}}}},"sort":[{"dateLastEdited":{"order":"desc","missing":"\_last"}},{"dateCreated":{"order":"desc","missing":"\_last"}}]}'

This runs perfectly when entered in a browser but through the RESTful client the error below is thrown.  
java.lang.IllegalStateException: Illegal character """ at position 6 is not allowed as a start of a name in a path template " -d '{"query":{...  
at org.glassfish.jersey.client.JerseyWebTarget.getUri(JerseyWebTarget.java:134)  
at org.glassfish.jersey.client.JerseyWebTarget.request(JerseyWebTarget.java:214)  
at org.glassfish.jersey.client.JerseyWebTarget.request(JerseyWebTarget.java:59)

What's possibly wrong here?

Your help will be greatly appreciated.

---

<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 17, 2016, 7:03am UTC](https://discuss.elastic.co/t/passing-json-query-in-gwt/66315/2 "2016-11-17T07:03:26Z")

</div>

Not related to elasticsearch here.

May be encode your text? Or use " instead of ".

Better to ask support in the REST client project you are using though.

---

<div class="post-metadata">

**Author:** ![Velusamy\_Velu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/velusamy_velu/32/72364_2.png) [@Velusamy\_Velu](https://discuss.elastic.co/u/Velusamy_Velu)\
**Post date:** [November 18, 2016, 12:42pm UTC](https://discuss.elastic.co/t/passing-json-query-in-gwt/66315/3 "2016-11-18T12:42:41Z")

</div>

Thank you for trying to help me. Changing " to " doesn't solve the problem. But I bet the problem is in the way the URL is constructed for Jersey. I'm still searching for the right forum to ask this question. No single forum seems to be the best to post this question.

I continued fiddling with the URL then found this format works [http://localhost](http://localhost):nnnn//drawings/\_search?xyz:1049279250

That's good but not sure how I can construct a complex query like that. Still seems to be a lot to learn.

---

<div class="post-metadata">

**Author:** ![Velusamy\_Velu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/velusamy_velu/32/72364_2.png) [@Velusamy\_Velu](https://discuss.elastic.co/u/Velusamy_Velu)\
**Post date:** [November 18, 2016, 1:29pm UTC](https://discuss.elastic.co/t/passing-json-query-in-gwt/66315/4 "2016-11-18T13:29:53Z")

</div>

I also tried enhancing the query by adding sort orders. This URL worked but not sure how Elasticsearch handles the query construct: [http://localhost](http://localhost):nnnn/index/drawings/\_search?pretty& visitorHashCode:1049279250& sort:dateLastEdited& order:desc& missing:\_last& dateCreated:order:desc& missing:\_last  
The above query works but I'm not sure how Elasticsearch handles the sort construct.

---

<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 16, 2016, 1:29pm UTC](https://discuss.elastic.co/t/passing-json-query-in-gwt/66315/5 "2016-12-16T13:29:59Z")

</div>

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