wood burning stoves 2.0*
The moose likes Web Services and the fly likes Rest jersey client passing json string to GET method for filter output Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Rest jersey client passing json string to GET method for filter output" Watch "Rest jersey client passing json string to GET method for filter output" New topic
Author

Rest jersey client passing json string to GET method for filter output

aditya sam
Greenhorn

Joined: Jun 12, 2014
Posts: 1
Hi,
I want to pass string {"filters":{"keyword":"abc"}} in this format as filter or search parameter to GET method for REST api url.

I want to convert curl parameters to get method to jersey rest call, the inline curl when executed from linux box works for me
curl -i -H "accept: application/json" -H "Content-type: application/json" -X GET -d '{ "filters": { "keyword":"xyz" } }' ../v1/users?token=[api_token] .

I tried using the inline code but with less luck
Client client = Client.create();
WebResource webResource = client.resource(url);
ClientResponse response2 = null;
MultivaluedMap<String, String> queryParams;
List<String> list = new ArrayList<String>();
list = Arrays.asList(new String[]{"{keyword:xyz}"});
String lst = (list.toString()).substring(1, list.toString().length()-1);
queryParams.add("filters", lst);
response2 = webResource.queryParams(queryParams).header("Content-Type", "application/json;charset=UTF-8").get(ClientResponse.class);
System.out.println("Response Code = "+response2.getStatus());
outputFilter = response2.getEntity(String.class);

Is there another way from where i can pass string as input paramters to GET method and retrieve the associated result Please suggest if there is any technique from where i can pass the above mentioned string to GET method and retrieve data as per filter applied
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Rest jersey client passing json string to GET method for filter output
 
Similar Threads
[jersey/jax-rs] json object value string has extra quotes, jsonp, service chaining‏
Problem with Rest Client
Receiving HTTP 405 When trying to use Jersey Client to Process POST to Web Service
JAXB Based JSON support not working with Jersey JAX-RS
curl data is not processed in POST request