title: content-length in HttpURLConnection
body: <p>I'm trying to send a body in <code>x-www-form-urlencoded</code> to my local Web API. I can make <code>GET</code> without any problems. Here is what I do:</p>
  
  <pre><code>    String urlParameters = "user=User&amp;label=GPU+Temp&amp;file=src%2FDataSource0.txt&amp;backgroundColor=rgb(255%2C255%2C255%2C0)&amp;borderColor=rgb(255%2C255%2C255%2C0)&amp;pointBorderColor=rgb(255%2C255%2C255%2C0)&amp;pointHoverBackgroundColor=rgb(255%2C255%2C255%2C0)&amp;pointHoverBorderColor=rgb(255%2C255%2C255%2C0)&amp;min=0&amp;max=100&amp;stepSize=50";
  
      byte[] postData = urlParameters.getBytes(Charset.forName("UTF-8"));
      int postDataLength = postData.length;
      String request = "http://192.168.1.30:6262/api/values";
      URL url = new URL(request);
      con = (HttpURLConnection) url.openConnection();
      con.setDoOutput(true);
      con.setInstanceFollowRedirects(false);
      con.setRequestMethod("POST");
      con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
      con.setRequestProperty("charset", "utf-8");
      con.setRequestProperty("Content-Length", Integer.toString(postDataLength));
      con.connect();
  </code></pre>
  
  <blockquote>
    <p>java.net.ProtocolException: content-length promised 598 bytes, but received 0</p>
  </blockquote>
  
  <p>So it means that I'm not sending any data in my <code>POST</code>, how come?</p>