title: How to properly get the body of a WebTarget get request response (JAX-RS)?
body: <p>How do i get the body of a HTTP get request with the <strong>javax.ws.rs</strong> library?</p>
  
  <p><strong><em>I tried:</em></strong></p>
  
  <pre><code>Response response = service.path(path).request().get();
  String body = response.readEntity(String.class);
  </code></pre>
  
  <p>but that doesn't work. Instead i get this exception: <strong><code>java.lang.NoClassDefFoundError: javax/ws/rs/core/NoContentException</code></strong></p>
  
  <p><strong><em>Then i tried:</em></strong></p>
  
  <pre><code>Response response = service.path(path).request(MediaType.APPLICATION_JSON_TYPE).get();
  String body = response.readEntity(JSONObject.class);
  </code></pre>
  
  <p>because I should actually get a JSON String back but i don't need it as JSON Object, that's the reason why i tried it like above before.</p>
  
  <p>But that doesn't work at all, i even can't compile and get the (IntelliJ) message 
  <code>no instance(s) of type variable(s) exist so that JSONObject conforms to String inference variable T has incompatible bounds: equality constraints: JSONObject upper bounds: Object, String</code></p>
  
  <p><strong><em>Addition:</em></strong> </p>
  
  <p>I get 200 as response status so everything worked fine and when i do the same in e.g. Postman or Fiddler it works.</p>