aditya sam

Greenhorn
+ Follow
since Jun 12, 2014
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by aditya sam

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
9 years ago