title: Consuming xml using HttpClient from webapi
body: <p>I used WebClient to get an Xml object from a restfull service (.net web api) and everything worked great:</p>
  
  <pre><code>using(WebClient client = new WebClient())
  {
     client.Encoding = UTF8Encoding.UTF8;
     client.Headers[HttpRequestHeader.ContentType] = "text/xml";
     client.Credentials = // ....;
     xmlResult = webClient.DownloadString(url);
  }
  
  ....
  </code></pre>
  
  <p>this code works great. I get an Xml as a string back, everyone's happy.</p>
  
  <p>Now, I changed it so it would work with HttpClient instead and I can't get an Xml returned - always a json as a string.</p>
  
  <pre><code>using(var handler = new HttpClientHandler() {Credentials = new NetworkCredentials})
  using(var client = new HttpClient(handler))
  {
     var request = new HttpRequestMessage(HttpMethod.Get, url);
     request.Headers.Add(HttpRequestHeader.ContentType.ToString(), "text/xml");
     returnedXml = client.SendAsync(request).Result.Content.ReadAsStringAsync().Result;
  }   
  </code></pre>
  
  <p>What am I doing wrong? How can I get the Xml I long for?</p>
  
  <p>Thanks</p>