title: Using the WebApiContrib ProtoBufFormatter on the Client Side
body: <p>I'm using the WebApiContrib.Formatting.ProtoBuf NuGet package (<a href="http://nuget.org/packages/WebApiContrib.Formatting.ProtoBuf/0.9.5.0" rel="nofollow">http://nuget.org/packages/WebApiContrib.Formatting.ProtoBuf/0.9.5.0</a>) to add support for Protocol Buffers in my Web API project.</p>
  
  <p>The server side seems to work great, but I've been unable to get the Web API Client libraries to deserialize a server response.</p>
  
  <pre><code>System.InvalidOperationException: Type is not expected, and no contract can be inferred: System.Collections.Generic.IEnumerable`1[[WebAPITest1.Protocol.Messages.Product, WebAPITest1.Protocol.Messages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]
  </code></pre>
  
  <p>Here is my client code:</p>
  
  <pre><code>var httpClient = new HttpClient();
  httpClient.BaseAddress = new Uri(@"http://localhost:60500/");
  httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/x-protobuf"));
  var response = httpClient.GetAsync("/api/products?$orderby=Name").Result;
  Assert.IsTrue(response.IsSuccessStatusCode);
  
  var products = response.Content.ReadAsAsync&lt;IEnumerable&lt;Product&gt;&gt;(new[]{new ProtoBufFormatter()}).Result;
  Assert.IsTrue(products.Count() &gt; 0);
  </code></pre>
  
  <p>Ideas?</p>