How to retrieve JSON Response from a javax.ws.rs.core.Response response?

pseudoCoder picture pseudoCoder · Aug 8, 2014 · Viewed 56.4k times · Source

I am making a request to an API and getting a response status code of 200.

Response of the api includes a json response.

import javax.ws.rs.core.Response;

Response response = webclient.post(SomeReqString);

How can I retrieve the json response as string from the web client response?

Answer

whoami picture whoami · Jun 17, 2015

You can use following code

String responseAsString = response.readEntity(String.class);