title: Cannot get JSON data from Jersey GET response
body: <p>I was developing a restful web client and trying to get the JSON payload from the response of a GET method. I am using Jersey. But I just cannot read the JSON data using response.getEntity() method. I tried many methods including response.bufferEntity(), but the output always kept empty. Below is my code and output, and in addition I can see the JSON data right in the response packet captured in wireshark. I would really appreciate everyone trying to help figure out why or provide solution. Thank you!</p>
  
  <p>Code:</p>
  
  <pre><code>    public JSONObject Get(String requestPath){
  
      ClientResponse response = webResource.path(requestPath)
              .header("Content-Type", contTypeHeader )
              .header("Accept",acceptHeader)
              .header("Authorization", authZ )
              .get(ClientResponse.class);
  
      response.bufferEntity();
      if (!(response.getStatus() == 201 || response.getStatus() == 200)) {
          throw new RuntimeException("Failed : HTTP error code : " + response.getStatus());
      }
  
      System.out.println(response.getEntity(JSONObject.class));
      return null;
  
  }
  </code></pre>
  
  <p>and the output is always like this: {}</p>