title: How to get content body from a httpclient call?
body: <p>I've been trying to figure out how to read the contents of a httpclient call, and I can't seem to get it. The response status I get is 200, but I can't figure out how to get to the actual Json being returned, which is all I need!</p>
  
  <p>The following is my code: </p>
  
  <pre><code>async Task&lt;string&gt; GetResponseString(string text)
  {
      var httpClient = new HttpClient();
  
      var parameters = new Dictionary&lt;string, string&gt;();
      parameters["text"] = text;
      Task&lt;HttpResponseMessage&gt; response = 
          httpClient.PostAsync(BaseUri, new FormUrlEncodedContent(parameters));
  
      return await response.Result.Content.ReadAsStringAsync();
  }
  </code></pre>
  
  <p>And I am getting it just calling it from a method:</p>
  
  <pre><code>Task&lt;string&gt; result =  GetResponseString(text);
  </code></pre>
  
  <p>And This is what I get </p>
  
  <blockquote>
    <p><code>response Id = 89, Status = RanToCompletion, Method = "{null}", Result = "StatusCode: 200, ReasonPhrase: 'OK', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:\r\n{\r\n  Connection: keep-alive\r\n  Date: Mon, 27 Oct 2014 21:56:43 GMT\r\n  ETag: \"5a266b16b9dccea99d3e76bf8c1253e0\"\r\n  Server: nginx/0.7.65\r\n  Content-Length: 125\r\n  Content-Type: application/json\r\n}"  System.Threading.Tasks.Task&lt;System.Net.Http.HttpResponseMessage&gt;</code></p>
  </blockquote>
  
  <p><strong>Update:</strong> This is my current code per Nathan's response below</p>
  
  <pre><code>    async Task&lt;string&gt; GetResponseString(string text)
      {
          var httpClient = new HttpClient();
  
          var parameters = new Dictionary&lt;string, string&gt;();
          parameters["text"] = text;
  
          var response = await httpClient.PostAsync(BaseUri, new FormUrlEncodedContent(parameters));
          var contents = await response.Content.ReadAsStringAsync();
  
          return contents;
      }
  </code></pre>
  
  <p>And I call it from this method....</p>
  
  <pre><code> string AnalyzeSingle(string text)
      {
          try
          {
              Task&lt;string&gt; result = GetResponseString(text);
              var model = JsonConvert.DeserializeObject&lt;SentimentJsonModel&gt;(result.Result);
  
              if (Convert.ToInt16(model.pos) == 1)
              {
                  _numRetries = 0;
                  return "positive";
              }
  
              if (Convert.ToInt16(model.neg) == 1)
              {
                  _numRetries = 0;
                  return "negative";
              }
  
              if (Convert.ToInt16(model.mid) == 1)
              {
                  _numRetries = 0;
                  return "neutral";
              }
  
              return "";
          }
          catch (Exception e)
          {
              if (_numRetries &gt; 3)
              {
                  LogThis(string.Format("Exception caught [{0}] .... skipping", e.Message));
                  _numRetries = 0;
                  return "";
              }
              _numRetries++;
              return AnalyzeSingle(text);
          }
      }
  </code></pre>
  
  <p>And it keeps running forever, It hits the line 
  <code>var model = JsonConvert.DeserializeObject&lt;SentimentJsonModel&gt;(result.Result);</code>
  Once, and it continues to go without stopping at another breakpoint.</p>
  
  <p>When I pause execution, It say </p>
  
  <blockquote>
    <p>Id = Cannot evaluate expression because the code of the current method is optimized., Status = Cannot evaluate expression because the code of the current method is optimized., Method = Cannot evaluate expression because the code of the current method is optimized., Result = Cannot evaluate expression because the code of the current method is optimized.</p>
  </blockquote>
  
  <p>.. I Continue execution, but it just runs forever. Not sure what the problem is</p>