title: c# httpclient POST request: cant send special characters
body: <p>I have a program that should login to site, it uses POST requests, and all goes fine, until one of the values contain special character('%' for example).</p>
  
  <pre><code>    captcha = "ABCDE" //all goes fine and well, server accept captcha
      captcha = "ABC&amp;%" //server dont accept captcha and return fail
  
      //here is the bad part:
      string request = "password=" + HttpUtility.UrlEncode(encpass, Encoding.UTF8) +
   "&amp;username=" + login + "&amp;captcha_text=" + HttpUtility.UrlEncode(captcha, Encoding.UTF8);
  </code></pre>
  
  <p>Also, i ofcourse googled it, and checked all i could find. I though i need to "warn" server abaut encoding, so i added </p>
  
  <pre><code>request.Headers.TryAddWithoutValidation("Content-Type", @"application/x-www-form-urlencoded; charset=UTF-8");
  </code></pre>
  
  <p>but it still did not helped me.</p>
  
  <p>Content types and way request should look like i get from Firebug, so if i can find some answers there - please point.</p>
  
  <p><strong>modify0:</strong> Also, i compared what my program send to server with browser request(using Firebug) and my request is completley same. Only difference - my request dont get accepted in values it contain special-characters.</p>
  
  <p><strong>modify1:</strong> Also, server have no problems handling special-characters when i check it in browser. For example it(browser) sent "K&amp;YF82" as "captcha_text=K%26YF82"(same value in addres propereties and request body) and all worked fine. UrlEncode do same replacement, but in my program it doesnt get accepted by server.</p>
  
  <p><strong>SOLUTION:</strong></p>
  
  <pre><code>{ password:"df464dsj", username:"username", captchaText:"ABC&amp;%", remember_login:"false" }
  </code></pre>
  
  <p>insteat of </p>
  
  <pre><code>password=f2341f14f&amp;username=username&amp;captha...
  </code></pre>