title: InvalidOperationException thrown in Http post when try to create HttpContent
body: <p>I've made an application which would need to Post data through http to a url, below is the code on how I post data:</p>
  
  <pre class="lang-c# prettyprint-override"><code>using(System.Net.Http.HttpClient client = new System.Net.Http.HttpClient()) {
      //Initialize a HttpClient
      client.BaseAddress = new Uri(strURL);
      client.Timeout = new TimeSpan(0, 0, 60);
      client.DefaultRequestHeaders.Accept.Clear();
  
      FormUrlEncodedContent formUrlEncodedContent = new FormUrlEncodedContent(convertNameValueCollectionToKeyValuePair(HttpUtility.ParseQueryString(objPostData.ToString())));
      //This is where I got stuck
      System.Net.Http.HttpContent content = new System.Net.Http.ObjectContent&lt;FormUrlEncodedContent&gt; (formUrlEncodedContent, new System.Net.Http.Formatting.FormUrlEncodedMediaTypeFormatter());
  
  
      using(System.Net.Http.HttpResponseMessage response = client.PostAsync(strAddr, content).Result) {}
  }
  
  protected static IEnumerable&lt;KeyValuePair&lt;string, string&gt;&gt; convertNameValueCollectionToKeyValuePair(NameValueCollection input) {
      var values = new List&lt;KeyValuePair&lt;string, string&gt;&gt;();
  
      foreach(var key in input.AllKeys) {
          values.Add(
          new KeyValuePair&lt;string, string&gt; (key, input[key]));
      }
  
      return values.AsEnumerable();
  }
  </code></pre>
  
  <p>The code runs smoothly until it ran into this line:</p>
  
  <pre><code>  System.Net.Http.HttpContent content = new System.Net.Http.ObjectContent&lt;FormUrlEncodedContent&gt;(formUrlEncodedContent, new System.Net.Http.Formatting.FormUrlEncodedMediaTypeFormatter());
  </code></pre>
  
  <p>The exception <code>The configured formatter 'System.Net.Http.Formatting.FormUrlEncodedMediaTypeFormatter' cannot write an object of type 'FormUrlEncodedContent'.</code> flows</p>
  
  <p>What's wrong with the code?</p>