title: How to add a body to a GET request in JAX-RS
body: <p>I'm trying to consume a REST API that requires a body with a GET request. But as a GET usually doesn't have a body, I can't find a way to attach a body in my request. I am also building the REST API, but the professor won't allow us to change the method to POST (he gave us a list of the endpoints we are to create, no more, no less).</p>
  
  <p>I'm trying to do it like this:</p>
  
  <pre><code>Response r = target.request().method(method, Entity.text(body));
  </code></pre>
  
  <p>Where I set the <code>method</code> to <code>GET</code> and the <code>body</code> to <code>my get body</code>. However, using this approach I get an exception:</p>
  
  <pre><code>javax.ws.rs.ProcessingException: RESTEASY004565: A GET request cannot have a body.
  </code></pre>
  
  <p>Is there any way to do this with JAX-RS? We learned to use JAX-RS so I would prefer a solution using this, as I'm not sure my professor would allow us to use any other REST client. I'm currently using RESTEasy, provided by the WildFly server.</p>
  
  <p>(This is not a duplicate of <a href="https://stackoverflow.com/questions/978061/http-get-with-request-body">HTTP GET with request body</a> because I'm asking on how to create a GET request with body in JAX-RS, not if it should be done.)</p>