title: Deserialize webapi repsonse to mvc4 viewmodel in application
body: <p>I am trying to setup and consume an asp.net webapi rest application and consume it from another project.</p>
  
  <p>I have made a simple helper to call the service like</p>
  
  <pre><code>public static string GetApiResponse(string apiMethod,Dictionary&lt;string,string&gt;queryString=null)
      {
          using (var client = new WebClient())
          {
              client.Headers.Add("ApiKey", ConfigurationManager.AppSettings["ApiKey"]);
              //add any query string values into the client
              if (queryString != null)
              {
                  foreach (var query in queryString)
                  {
                      client.QueryString.Add(query.Key, query.Value);
                  }
              }
              try
              {
                 string url = string.Format("{0}{1}", ConfigurationManager.AppSettings["ApiBaseUrl"],apiMethod);
                 return(client.DownloadString(url));
              }
              catch (Exception ex)
              {
                  return ex.Message;
              }
  
          }
      }
  </code></pre>
  
  <p>I am consuming it from my controller in a different project like</p>
  
  <pre><code>  private IEnumerable&lt;CustomerModel&gt; CustomerDetails()
      {
          var json = ApiRestHelper.GetApiResponse("Customer/Get");
  
          var data = JsonConvert.DeserializeObject&lt;CustomerViewModel&gt;(json, new JsonSerializerSettings
                                                                            {
  
                                                                            });
  </code></pre>
  
  <p>The returned data from the service is looking like</p>
  
  <pre><code>[{"CustomerId":"24a62bf8-7a4e-4837-859d-1f04dc983011","FirstName":"Joe","LastName":"Bloggs","StoreCustomerId":null}]
  </code></pre>
  
  <p>My CustomerViewModel is </p>
  
  <pre><code> public class CustomerViewModel
  {
      public IEnumerable&lt;CustomerModel&gt; Customers { get; set; }
  }
  </code></pre>
  
  <p>I can see the data that is returned is an array and I am trying to convert it to the list. I get an error</p>
  
  <blockquote>
    <p>Cannot deserialize JSON array (i.e. [1,2,3]) into type 'WebApplication.Models.ViewModels.CustomerViewModel'.</p>
  </blockquote>
  
  <p>The deserialized type must be an array or implement a collection interface like IEnumerable, ICollection or IList.</p>
  
  <p>What do I need to change to allow the deserialization into my view model?</p>