title: How to post raw json text in Jersey Client HTTP POST request?
body: <p>I want to make an <code>HTTP POST</code> request, which requires parameters must be passed as raw JSON text, but I don't know how to do in with Jersey client.<br>
  Here is the API specs (works well in Postman Rest Client): (please look at the screenshot from my Postman, the URL, parameter in body, and 2 headers are Content-Type: application/json &amp; Accept: application/json)
  <a href="https://i.stack.imgur.com/dGK4D.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/dGK4D.jpg" alt="Postman client"></a><br>
  And here is what I've tried with Jersey:</p>
  
  <pre><code>JsonObject parameters = new JsonObject();
  parameters.addProperty("centerId", centerId);
  parameters.addProperty("studentId", studentId);
  
  if (fromDate != null) {
      parameters.addProperty("fromDate", fromDate);
  }
  if (toDate != null) {
      parameters.addProperty("toDate", toDate);
  }
  
  Object response = client.target("http://localhost:8080/rest").path("student/calendar")
      .request(MediaType.APPLICATION_JSON).post(Entity.json(parameters), String.class);
  </code></pre>
  
  <p>but nothing worked. Can anyone suggest what is the correct way to deal with Jersey in this case? Thank you.</p>