title: Consuming Web Api's as HttpPost
body: <p>Can somebody help me how to post an array of type long to a WebApi.</p>
  
  <p>I think I have to use PostAsync from HttpClient, but I am not sure how to put array to HttpContent.</p>
  
  <p>This is my controller.</p>
  
  <pre><code> [HttpPost]
   [Authorize]
   public void UpdateBatchesToReadyToShip(long[] batchIds)
   {
              // process request
    }
  </code></pre>
  
  <p>And this is how I am trying to consume API</p>
  
  <pre><code>var buffer = Encoding.ASCII.GetBytes("username:password");
  var authHeader = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(buffer));
  client.DefaultRequestHeaders.Authorization = authHeader;
  var arr = new long[3];
  arr[0] = 10;
  arr[1] = 12;
  arr[2] = 13;
  HttpContent content = new StringContent(string.Join(",", from i in arr select i.ToString()));
  var task = client.PostAsync("https://&lt;uri&gt;/api/orderprocessing/UpdateBatchesToReadyToShip",content:content);
  if (task.Result.StatusCode == HttpStatusCode.Unauthorized)
  {
  Console.WriteLine("wrong credentials");
  }
  else
  {
  //task.Result.EnsureSuccessStatusCode();
  HttpResponseMessage message = task.Result;
  if (message.IsSuccessStatusCode)
  {
  var details = message.Content.ReadAsStringAsync().Result;
  Console.Write(details);
  }
  }
  </code></pre>
  
  <p>And I am getting this exception</p>
  
  <pre><code>{StatusCode: 500, ReasonPhrase: 'Internal Server Error', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
  {
    Pragma: no-cache
    Cache-Control: no-cache
    Date: Fri, 09 Nov 2012 12:37:44 GMT
    Server: Microsoft-IIS/8.0
    X-AspNet-Version: 4.0.30319
    X-Powered-By: ASP.NET
    Content-Length: 1060
    Content-Type: application/json; charset=utf-8
    Expires: -1
  }}
  </code></pre>