title: How to call Rest API with Content and Headers in c#?
body: <p>I am trying to call Rest API with content and headers in c#. Actually I am trying to convert to c# from Python code which is:</p>
  
  <pre><code>import requests
  url = 'http://url.../token'
  payload = 'grant_type=password&amp;username=username&amp;password=password'
  headers = {
    'Content-Type': 'application/x-www-form-urlencoded'
  }
  response = requests.request('POST', url, headers = headers, data = payload, allow_redirects=False)
  print(response.text)
  </code></pre>
  
  <p>So far I am trying with:</p>
  
  <pre><code>HttpClient client = new HttpClient();
  client.BaseAddress = new Uri(Url);
  
  var tmp = new HttpRequestMessage
  {
      Method = HttpMethod.Post,
      Content =
              {
  
              }
       };
  
      var result = client.PostAsync(Url, tmp.Content).Result;
  }
  </code></pre>
  
  <p>I have no idea how to put from Python code Headers (Content-Type) and additional string (payload).</p>