title: HttpClient POST to WCF returns 400 Bad Request
body: <p>I have a WCF Service self-hosted which exposes a Web POST method with the following signature:</p>
  
  <pre><code>[ServiceContract]
  public interface IPublisherService
  {
      [OperationContract]
      [WebInvoke(UriTemplate = "Send", Method = "POST")]
      void SendMessage(string message);
  }
  </code></pre>
  
  <p>If I send a request using Fiddler with the following structure (<a href="http://localhost:8080/Publisher/Send" rel="nofollow noreferrer">http://localhost:8080/Publisher/Send</a>):</p>
  
  <p><a href="https://i.stack.imgur.com/eXxdj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eXxdj.png" alt="enter image description here"></a></p>
  
  <p>WCF returns 200 OK with the response correctly deserialized into JSON:</p>
  
  <p><a href="https://i.stack.imgur.com/RmRYZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RmRYZ.png" alt="enter image description here"></a></p>
  
  <p>But when I try to use <strong>HttpClient</strong> from a C# Console Application, I always get back a 400 Bad Request without any reason.
  This is the request:</p>
  
  <pre><code>using (HttpClient client = new HttpClient())
  {
      var content = new StringContent(this.view.Message);
      content.Headers.ContentType = new MediaTypeHeaderValue("Application/Json");
      var response = client.PostAsync(
          new Uri("http://localhost:8080/Publisher/Send"), 
          content);
      var result = response.Result;
      this.view.Message = result.ToString();
  }
  </code></pre>
  
  <p>And the response is always 400, doesn't matter if I use <em>client.PostAsync</em> or <em>clint.SendAsync</em>.</p>
  
  <pre><code>StatusCode: 400, ReasonPhrase: 'Bad Request', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
  {
    Date: Tue, 29 Dec 2015 12:41:55 GMT
    Server: Microsoft-HTTPAPI/2.0
    Content-Length: 1647
    Content-Type: text/html
  }
  </code></pre>