0

I want to call REST API for GET request in Java. I want to send some query parameters with the request. How to do it? The format of the curl command which I want to request is:

curl -G -X GET -H "Accept:application/rdf+xml" --data-urlencode text="Sachin Plays cricket" http://wit.istc.cnr.it/stlab/fred

1 Answers1

0

I guess you can use the jersey client to a get call

this is an example code:

WebResource webResource = client.resource("http://"my.server:8080/warAppp").path("restService/endpoint").
                                 queryParam("param1", "myFirstParam").
                                 queryParam("param2",String.valueOf(intValueToConverToString));
String result =webResource.type(MediaType.TEXT_PLAIN_TYPE).get(ClientResponse.class).getEntity(String.class);
zpontikas
  • 5,445
  • 2
  • 37
  • 41