title: Calculate Content.Length
body: <p>I am getting problems making a http POST. The API I am calling is asking for the <code>content-length</code>. But I am unsure how to do this.</p>
  
  <p>Here is the code I have:</p>
  
  <pre><code>public static string publishClip(string instance_url, string sessionId, string clipId)
  {
      int trev = System.Text.ASCIIEncoding.Unicode.GetByteCount(instance_url + "/services/apexrest/DesktopClient/PublishClip/" + clipId);
  
      WebRequest wrGETURL;
      wrGETURL = WebRequest
          .Create(instance_url
                  + "/services/apexrest/DesktopClient/PublishClip/"
                  + clipId);
      wrGETURL.Method = "POST";
      wrGETURL.ContentType = "application/json";
      wrGETURL.ContentLength = trev;
      wrGETURL.Headers.Add("Authorization", "Bearer " + sessionId);
      Stream objStreamclipId = wrGETURL.GetResponse().GetResponseStream();
      StreamReader objReader = new StreamReader(objStreamclipId);
  
      return "trev";
  }
  </code></pre>
  
  <p>Can anyone help me out please?</p>
  
  <p>This is the error I am getting:</p>
  
  <blockquote>
    <p>{"You must provide a request body if you set ContentLength>0 or SendChunked==true.  Do this by calling [Begin]GetRequestStream before [Begin]GetResponse."}</p>
  </blockquote>