Convert InboundJaxrsResponse to json string
<p>I am trying to serialize a jax-rs Response to json string.</p>

<p>The response from the server is json, and I get it from jersey client with:</p>

<pre><code>Response resp = target.request().method("PUT", Entity.json(payloadBean))
</code></pre>

<p>where payloadBean is my json request. Everything works fine but I cannot convert the resp in json string in order to log it.</p>

<p>If I try:</p>

<pre><code>String s = EntityUtils.toString((HttpEntity) resp.getEntity());
</code></pre>

<p>I get: </p>

<pre><code>org.glassfish.jersey.client.internal.HttpUrlConnector cannot be cast to org.apache.http.HttpEntity
</code></pre>

<p>By the way if I don't cast to HttpEntity, compiler says:</p>

<pre><code>toString (org.apache.http.HttpEntity) in EntityUtils cannot be applied to (java.lang.Object).
</code></pre>

<p>My relevant imports are:</p>

<pre><code>import org.apache.http.HttpEntity;
import org.apache.http.util.EntityUtils;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Entity;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.Response;
</code></pre>

<p>Any ideas?</p>