title: Unable to encode my JSON object inside my WebClient UploadString using Headers["Content-Type"] = "application/x-www-form-urlencoded"
body: <p>I am working on an ASP.Net MVC 4 web application and I need to post a JSON object to a 3rd part API. Now I need my JSON data to be encoded by setting the content type to be <code>application/x-www-form-urlencoded</code> as mentioned inside the API documentations. so I tried the following by specifying the <code>Content-Type</code> as <code>wc.Headers["Content-Type"] = "application/x-www-form-urlencoded";</code> :</p>
  
  <pre><code>var data = JsonConvert.SerializeObject(mainresourceinfo); 
  using (WebClient wc = new WebClient()) 
  {
      string url = currentURL + "resources?AUTHTOKEN=" + pmtoken;
      Uri uri = new Uri(url);
  
      //  wc.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
      wc.Headers["Content-Type"] = "application/x-www-form-urlencoded";
  
      crudoutput = wc.UploadString(uri, "INPUT_DATA=" + data);
  }
  </code></pre>
  
  <p>but still the data is not being encoded .. and if I send a value such as <code>123%456</code> inside my JSON string, it will be saved as <code>123E6t</code> inside the 3rd part system. now as a workaround i have manually encoded the JSON object using  <code>WebUtility.UrlEncode(data)</code> before sending it to the 3rd part API, and I can see that the values such as <code>123%456</code> will be saved correctly ...
  but I do not want to be manually encoding the data ,, I want to set the content type to specify the encoding ...is this possible?</p>