title: The correct way to PUT a JSON object to a RESTful server
body: <p>I am having trouble correctly formatting my PUT request to get my server to recognise my client application's PUT command.</p>
  
  <p>Here is my section of code that puts a JSON string to the server.</p>
  
  <pre><code>try {
      URI uri = new URI("the server address goes here");
      URL url = uri.toURL();
      URLConnection conn = url.openConnection();
      conn.setDoOutput(true);
      OutputStreamWriter out = new OutputStreamWriter(conn.getOutputStream());
      out.write(gson.toJson(newClient));
      out.close();
  } catch (Exception e) {
      Logger.getLogger(CATHomeMain.class.getName()).log(Level.SEVERE, null, e);
  }
  </code></pre>
  
  <p>and here is the code that is supposed to catch the PUT command</p>
  
  <pre><code>@PUT
  @Consumes("text/plain")
  public void postAddClient(String content, @PathParam("var1") String var1, @PathParam("var2") String var2) {
  </code></pre>
  
  <p>What am I doing wrong?</p>