how to use client and webresource objects to do https call

The solution for “how to use client and webresource objects to do https call” can be found here. The following code will assist you in solving the problem.

Client client = Client.create();
WebResource webResource = client.resource(“uri”);

MultivaluedMap queryParams = new MultivaluedMapImpl();
queryParams.add(“json”, js); //set parametes for request

appKey = “Bearer ” + appKey; // appKey is unique number

//Get response from RESTful Server get(ClientResponse.class);
ClientResponse response = webResource.queryParams(queryParams)
.header(“Content-Type”, “application/json;charset=UTF-8”)
.header(“Authorization”, appKey)
.get(ClientResponse.class);

String jsonStr = response.getEntity(String.class);

Thank you for using DeclareCode; We hope you were able to resolve the issue.

More questions on [categories-list]

0
inline scripts encapsulated in