title: Using http client to send header and content via post
body: <p>I'm making a really simple call to an API to receive some data. I need to send headers to get authorized also I need to send some content on the body. This is what I came up with :</p>
  
  <pre><code>public async Task&lt;List&lt;LoremIpsum&gt;&gt; LoremIpsumJson()
      {
          LoremIpsum1 data = null;
          try
          {
              var client = new HttpClient();
              //now lets add headers . 1.method, 2.token
              client.DefaultRequestHeaders.Add("Method", "LoremIpsumExample");
              client.DefaultRequestHeaders.Add("Token", "sometoken");
              HttpContent content = new StringContent("{\"Name\":\"John\",\"Surname\":\"Doe\",\"Example\":\"SomeNumber\"}", Encoding.UTF8, "application/json");
              // ==edit==
               client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
              var response = await client.PostAsync("www.theUrlToTheApi", content);
              response.EnsureSuccessStatusCode();
              string json = await response.Content.ReadAsStringAsync();
              data = JsonConvert.DeserializeObject&lt;QueueInfo&gt;(json);
          }
          catch(Exception ex)
          {
              Debug.WriteLine(ex.Message.ToString());
          }
          return data.data;
          Debug.WriteLine(data.data);
      }
  </code></pre>
  
  <p>The app breaks after <code>response.EnsureSuccessStatusCode();</code> because the request obviously is not successful. 
  I think I'm really missing something really simple here. How can I do this call?
  The error is </p>
  
  <blockquote>
    <p>StatusCode: 406, ReasonPhrase: 'Not Acceptable'</p>
  </blockquote>