title: HttpClient - System.Net.Http.UnsupportedMediaTypeException - Server StatusCode 500
body: <p>Here's my WCF service contract, one of the method sigs:</p>
  
  <pre><code>[WebInvoke(UriTemplate = "", Method = "POST")]
  public InventoryResponse Post(InventoryRequest inventoryRequest)
  {
  </code></pre>
  
  <p>This REST endpoint works in fiddler when I make a POST request to that endpoint, I DO successfully get back json:</p>
  
  <p>Endpoint I'm posting to: <code>http://localhost/Inventory/</code></p>
  
  <p><img src="https://i.stack.imgur.com/oz8AL.jpg" alt="enter image description here"></p>
  
  <p><img src="https://i.stack.imgur.com/B3kQH.jpg" alt="enter image description here"></p>
  
  <p>Headers:</p>
  
  <p><img src="https://i.stack.imgur.com/QQr5f.jpg" alt="enter image description here"></p>
  
  <p>However this does not and it's trying to make a call to the same url.  I end up getting back a 500 server-side error in the respnse saying "Internal Server Error" which probably means that some code failed but then how come the fiddler call works...seems like that doesn't add up.</p>
  
  <pre><code>    using (var client = new HttpClient())
      {
          var postUri= "http://localhost/Inventory/";
          client.BaseAddress = new Uri(postUri);
          client.DefaultRequestHeaders.Accept.Clear();
          client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
  
          inventoryResponse = client.PostAsJsonAsync("", inventoryRequest).Result.Content.ReadAsAsync&lt;InventoryResponse&gt;().Result;
  
      }
  </code></pre>
  
  <p>This error says I think that I did not get a json object back from the service:</p>
  
  <pre><code>    System.Net.Http.UnsupportedMediaTypeException: No MediaTypeFormatter is available to read an object of type 'InventoryResponse' from content with media type 'text/html'.
  
  System.AggregateException: One or more errors occurred. ---&gt; System.Runtime.Serialization.SerializationException: Error in line 1 position 70. Expecting element 'InventoryPostResponse' from namespace 'http://schemas.datacontract.org/2004/07/EventInventory.Applications.WebService.Jetson.Responses.BulkPosting'.. Encountered 'Element'  with name 'Fault', namespace 'http://schemas.microsoft.com/ws/2005/05/envelope/none'. 
  </code></pre>