title: How to POST json as request body with Jetty http client?
body: <p>I'm stuck with adding JSON to POST request body. There just isn't any method that sets the body of the request.</p>
  
  <p>Is there any way I can achieve this. Otherwise I have to drop using Jetty.</p>
  
  <p>This is how I make my POST request:</p>
  
  <pre><code>Request request = httpClient.POST(url);
          //request.method(HttpMethod.POST);
          request.header(HttpHeader.ACCEPT, "application/json");
          request.header(HttpHeader.CONTENT_TYPE, "application/json");
  
          // Add basic auth header if credentials provided
          if (isCredsAvailable()) {
              String authString = username + ":" + password;
              byte[] authEncBytes = Base64.getEncoder().encode(authString.getBytes());
              String authStringEnc = "Basic " + new String(authEncBytes);
              request.header(HttpHeader.AUTHORIZATION, authStringEnc);
          }
  
          request(send);
  </code></pre>
  
  <p>Any help is appreciated!</p>