I am using jersey client to post a file to a REST URI that returns response as json. My requirement is to read the response as is(json) to a string.
Here is the piece of
Although the above answer is correct, using Jersey API v2.7 it is slightly different with Response
:
Client client = ClientBuilder.newClient();
WebTarget target = client.target("http://localhost:8080");
Response response = target.path("api").path("server").path("ping").request(MediaType.TEXT_PLAIN_TYPE).get();
System.out.println("Response: " + response.getStatus() + " - " + response.readEntity(String.class));