title: How to consume an ArrayList in c# from RESTful API?
body: <p>I have deployed a REST API in IIS, in which a GET method returns an Arraylist of Student Class. How can I consume XML root Element "ArrayOfStudent" in c# using HttpClient? Below is the code I have written so far.</p>
  
  <p>API get method</p>
  
  <pre><code>[HttpGet]
  [ResponseType(typeof(IEnumerable&lt;Student&gt;))]
  public IHttpActionResult Get()
  {
       using (handler) //handler is just EF code to get data
       {
          return Ok(handler.Get());
       }
  }
  </code></pre>
  
  <p>API XML response</p>
  
  <pre><code>&lt;ArrayOfStudent xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/Com.CompanyName.Component.Entity"&gt;
     &lt;Student&gt;
        &lt;Id&gt;1&lt;/Id&gt;
        &lt;Name&gt;John&lt;/Name&gt;
     &lt;/Student&gt;
  &lt;/ArrayOfStudent&gt;
  </code></pre>
  
  <p>Http Client Code</p>
  
  <pre><code> static void Main(string[] args)
          {
  
              HttpClient client = new HttpClient();
              client.BaseAddress = new Uri("http://localhost:55587/");
              client.DefaultRequestHeaders.Accept.Clear();
              client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/xml"));
  
              Task&lt;HttpResponseMessage&gt; responseTask = client.GetAsync("api/Student");
              responseTask.Wait();
  
              ///////Error is on this line of code ////////
              var ListTask = responseTask.Content.ReadAsAsync&lt;IEnumerable&lt;Student&gt;&gt;();
              ListTask.Wait();
  
              IEnumerable&lt;Student&gt; list = ListTask.Result;
              return list;
  
          }
  </code></pre>
  
  <p>Inner Exception</p>
  
  <pre><code>Inner Exception 1:
  SerializationException: Error in line 1 position 150. Expecting element 'ArrayOfStudent' from namespace 'http://schemas.datacontract.org/2004/07/Com.CompanyName.ApiAgent.Entity'.. Encountered 'Element'  with name 'ArrayOfStudent', namespace 'http://schemas.datacontract.org/2004/07/Com.CompanyName.Component.Entity'. 
  </code></pre>
  
  <p>Student class -- Simple </p>
  
  <pre><code>using System;
  
  namespace Com.CompanyName.Entity
  {
      public class Student
      {
          public long Id { get; set; }
          public string Name { get; set; }
  
      }
  }
  </code></pre>