title: How can I capture the HttpResponseMessage.Content after a PostAsJsonAsync for our records?
body: <p>We're posting JSON to a service that records actions when a change is made from our website.  After posting the JSON, we'd like to capture the Content from the response message to record it.</p>
  
  <p>In the Visual Studio watch pane I can see the Content, which looks something like this after a post:</p>
  
  <blockquote>
    <p>Id = 4, Status = RanToCompletion, Method = "{null}", Result = "[]"</p>
  </blockquote>
  
  <p>The above result appears after this statement in watch:</p>
  
  <blockquote>
    <p>httpResponseMessage.Content.ReadAsStringAsync(), ac</p>
  </blockquote>
  
  <p>But whenever I attempt to assign the response content to a string, the string value is merely "[]", instead of the list of properties (ID, Status, etc) I expected to see above.</p>
  
  <p>Here is a simplified section of code (try/catch and other pieces omitted). After the PostAsJsonAsync, we get a 200 success status code.</p>
  
  <pre><code>public HttpResponseMessage httpResponseMessage { get; set; }
  public string httpResponseMessageContent { get; set; }
  
  private async Task SendMaintenanceEvent(object maintenanceEvent)
  {
      string endpointAddress = "http://whereever";
      string targetDirectory = "OurTarget";
      string credentials = "Omitted";
      string credentialsBase64 = Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(credentials));
      string maintenanceEventAsJSON = System.Web.Helpers.Json.Encode(maintenanceEvent);
      StringContent stringContent = new StringContent(maintenanceEventAsJSON, Encoding.UTF8, "application/json");
  
      using (HttpClient httpClient = new HttpClient())
      {
          httpClient.BaseAddress = new Uri(endpointAddress);
          httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", credentialsBase64);
          this.httpResponseMessage = await httpClient.PostAsJsonAsync(targetDirectory, stringContent).ConfigureAwait(false);
          if (httpResponseMessage.IsSuccessStatusCode)
          {
              // Current value: "[]"
              // Expected value: Id = 4, Status = RanToCompletion, Method = "{null}", Result = "[]"
              this.httpResponseMessageContent = await httpResponseMessage.Content.ReadAsStringAsync();
          }
          else
          {
              throw new System.Exception("Error sending maintenance event.");
          }
      }
  }
  </code></pre>
  
  <p>Thanks for your help.</p>