title: No MediaTypeFormatter is available to read an object of type 'MYAPI' from content with media type 'application/xml'
body: <p>I have my API response like this:</p>
  
  <pre><code>&lt;MYAPI xsi:noNamespaceSchemaLocation="MYAPI.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
     &lt;SomeTask LastModified = "Some Date" Resource="Some Resource Name"&gt;
         &lt;Name&gt;Some Name&lt;/Name&gt;
         &lt;ID&gt;Some ID&lt;/ID&gt;  
      &lt;/SomeTask&gt;
      ... A lot of these &lt;SomeTask&gt;...&lt;/SomeTask&gt; are there    
  &lt;/MYAPI&gt;
  </code></pre>
  
  <p>I've modeled the class for it as:</p>
  
  <pre><code>XmlRoot(ElementName = "MYAPI")]
  class MYAPI
  {
      [XmlElement(ElementName = "SomeTask")]
      public List&lt;SomeTask&gt; SomeTask{ get; set; }
  }
  
  [XmlRoot(ElementName="SomeTask")]
  public class SomeTask {
      [XmlElement(ElementName="Name")]
      public string Name { get; set; }
      [XmlElement(ElementName="ID")]
      public string ID { get; set; }
      [XmlAttribute(AttributeName="LastModified")]
      public string LastModified { get; set; }
      [XmlAttribute(AttributeName="Resource")]
      public string Resource { get; set; }
  }
  </code></pre>
  
  <p>And I'm trying to read it like this:</p>
  
  <pre><code>static void Main()
  {
      var handler = new HttpClientHandler();
      handler.Credentials = new NetworkCredential("MyUsername", "MyPassword");
  
      var client = new HttpClient(handler);
      client.BaseAddress = new Uri("https://sitename.com:PortNumber/");
      client.DefaultRequestHeaders.Accept.Clear();
      client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/xml"));
  
      var formatters = new List&lt;MediaTypeFormatter&gt;() 
      {
          new XmlMediaTypeFormatter(){ UseXmlSerializer = true } 
      };
  
      var myApi = new MYAPI();
      HttpResponseMessage response = client.GetAsync("/api/mysites/tasks").Result;
  
      if (response.IsSuccessStatusCode)
      {
  
          myApi = response.Content.ReadAsAsync&lt;MYAPI&gt;(formatters).Result;
      }
  }
  </code></pre>
  
  <p>But with this code, I'm always getting this exception:
  <code>No MediaTypeFormatter is available to read an object of type 'MYAPI' from content with media type 'application/xml'.</code></p>
  
  <p>Would someone please tell me how to fix this one? Thank You!</p>