title: Getting response body on failed request with HttpRequestException
body: <p>I am trying to log failed requests from my <code>HttpRequestException</code>.</p>
  
  <p>My server returns error code <strong>and</strong> additional JSON payload at the response body. I need to access that JSON. How do I read the response body in case of an errored request? I know that the actual response is not null. It's an API and I confirm that it returns JSON payload with 4xx status codes, giving detailed insight about the error.</p>
  
  <p>How do I access it? Here is my code:</p>
  
  <pre><code>using (var httpClient = new HttpClient())
  {
      try
      {
          string resultString = await httpClient.GetStringAsync(endpoint);
          var result = JsonConvert.DeserializeObject&lt;...&gt;(resultString);
          return result;
      }
      catch (HttpRequestException ex)
      {
          throw ex;
      }
  }
  </code></pre>
  
  <p>I am trying to get data in <code>throw ex</code> line, but I couldn't find a way.</p>