Is there a way to capture the error message using ServiceStack HttpUtils from my .NET 6 project. Now it returns an empty string...
try
{
var response = await GetApiUrl().CombineWith("/Controller/DoSomething").PostJsonToUrlAsync(body);
}
catch (Exception ex)
{
var errorBody = await ex.GetResponseBodyAsync();
}
GetResponseBodyAsync
only resolves .NET HttpWebRequest response bodies, it's too late to read the body from the HttpClient exception, you'd need to use the HttpClient directly to be able to read the body from failed responses.