I am using jersey-client-1.9
. sample code:
import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.WebResource;
Client client = Client.create();
webResource = client.resource("http://localhost:8047/storage/hive.json");
String input = //rest request
ClientResponse response = webResource.type("application/json").post(ClientResponse.class, input);
String queryRespose = response.getEntity(String.class);
As this project has changed from com.sun.jersey.api.client
to org.glassfish.jersey.client
. How to achieve this in jersey-client-2.8
?
Edit:
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Entity;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.Response;
Client client = ClientBuilder.newClient();
WebTarget target = client.target("http://localhost:8047/query.json");
String input =//rest request
Response response = target.request().post(Entity.json(input));
String queryRespose = response.readEntity(String.class);
This worked...:)
com.sun.jersey
in the exception message. You need to get rid of anything Jersey 1.x (com.sun.jersey
) related if you're going to use Jersey 2.x (org.glassfish.jersey
) – Clientage