title: HttpClient returning Bad Request while Postman is working fine
body: <p>I've seen a pretty similar question <a href="https://stackoverflow.com/questions/41660792/httpclient-postasync-posting-null-content">here</a> ("httpclient-postasync-posting-null-content"). In my case I make an instance of <code>HttpClient</code> in the constructor :</p>
  
  <pre><code>_client = new HttpClient();
  </code></pre>
  
  <p>And later on in one of my methods I'm doing this:</p>
  
  <pre><code>_client.DefaultRequestHeaders.Accept.Clear();
  _client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
  var content = new StringContent("", Encoding.UTF8, "application/json");
  
  string targetUrl = //the url
  var httpResponse = await _client.PostAsync(targetUrl,content);
  </code></pre>
  
  <p>So basically that's it. One of the problem is that currently as the request is not working if I leave this row like this:</p>
  
  <pre><code>var httpResponse = await _client.PostAsync(targetUrl,content);
  </code></pre>
  
  <p>It actually hangs forever. So for the sake of finding out what is happening I've made this change:</p>
  
  <pre><code>var httpResponse = _client.PostAsync(targetUrl, content).Result;
  </code></pre>
  
  <p>which actuaylly returns result but it's <code>Bad Request</code>. However the very same request executed from Postman is working just fine.</p>
  
  <p>Also form the question that I've linked above I'm starting to get a feeling that this probably is somehow related to the <code>string</code> type and some specific cases when you try to send a <code>string</code> in a <code>POST</code> request. Friday I think I had a similar issue when I tried to send some simple string like <code>"23423-32432-sfg-43324"</code> with <code>RestSharp</code> and again, it was not working but the <code>Postman</code> was doing just fine.</p>
  
  <p>My assumption is that <code>Postman</code> makes some modifications on the <code>string</code> before actually posting it, but anyways. Can someone help me here and eventually provide explanation why this happens - the same request is working from <code>Postman</code> but failing in the code?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Adding this line fix it:</p>
  
  <pre><code>System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
  </code></pre>
  
  <p>Not sure if this is something specific or a more common problem. May leave it just in case someone else have the same problem.</p>