title: How to parse PostAsync response from Bing 2 API in C#?
body: <p>Bing put out a new version (2) of their Search API several months ago.  MS Cognitive Services provides examples of using their new Search API 2.<br>
  <a href="https://dev.cognitive.microsoft.com/docs/services/56b43f0ccf5ff8098cef3808/operations/571fab09dbe2d933e891028f" rel="nofollow noreferrer">https://dev.cognitive.microsoft.com/docs/services/56b43f0ccf5ff8098cef3808/operations/571fab09dbe2d933e891028f</a></p>
  
  <p>However the worked examples are with XML responses and there is only a partial C# example which makes the call, but doesn't decode the result.  </p>
  
  <p>Can someone pls explain or continue the sample code in order to parse the returned object into actual images or image-URLs?  In the code below, the "content" variable is of type ByteArrayContent, but what is required to grab the information from this array?  The "response" variable is of type HttpResponseMessage, but how to extract images or image-URLs from it?</p>
  
  <p>This would allow an application to  select and display one or more of the returned images.  </p>
  
  <p>Many thanks, Tim</p>
  
  <p>Here's the C# code sample:</p>
  
  <pre><code>using System;
  using System.Net.Http.Headers;
  using System.Text;
  using System.Net.Http;
  using System.Web;
  
  namespace CSHttpClientSample
  {
      static class Program
      {
          static void Main()
          {
              MakeRequest();
              Console.WriteLine("Hit ENTER to exit...");
              Console.ReadLine();
          }
  
          static async void MakeRequest()
          {
              var client = new HttpClient();
              var queryString = HttpUtility.ParseQueryString(string.Empty);
  
              // Request headers
              client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", 
              "{subscription key}");
  
              // Request parameters
              queryString["q"] = "cats";
              var uri = 
                  "https://api.cognitive.microsoft.com/bing/v5.0/images/search?" 
                  + queryString;
  
              HttpResponseMessage response;
  
              // Request body
              byte[] byteData = Encoding.UTF8.GetBytes("{body}");
  
              using (var content = new ByteArrayContent(byteData))
              {
                 content.Headers.ContentType = new MediaTypeHeaderValue(
                 "&lt; your content type, i.e. application/json &gt;");
                 response = await client.PostAsync(uri, content);
              }
  
          }
      }
  }   
  </code></pre>