title: How to add and get Header values in WebApi
body: <p>I need to create a POST method in WebApi so I can send data from application to WebApi method. I'm not able to get header value.</p>
  
  <p>Here I have added header values in the application:</p>
  
  <pre><code> using (var client = new WebClient())
          {
              // Set the header so it knows we are sending JSON.
              client.Headers[HttpRequestHeader.ContentType] = "application/json";
  
              client.Headers.Add("Custom", "sample");
              // Make the request
              var response = client.UploadString(url, jsonObj);
          }
  </code></pre>
  
  <p>Following the WebApi post method:</p>
  
  <pre><code> public string Postsam([FromBody]object jsonData)
      {
          HttpRequestMessage re = new HttpRequestMessage();
          var headers = re.Headers;
  
          if (headers.Contains("Custom"))
          {
              string token = headers.GetValues("Custom").First();
          }
      }
  </code></pre>
  
  <p>What is the correct method for getting header values?</p>
  
  <p>Thanks.</p>