-
-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
Currently, when consuming APIs that follow RFC 7807 (Problem Details for HTTP APIs), the autogenerated client does not expose response.Content in ApiException, making it difficult to access the actual error body content when an error (e.g., 400 Bad Request) is returned.
Structured error details should be returned in the body using application/problem+json, which requires access to response.Content. However, since the client does not expose this directly, we are forced to intercept it by implementing a partial method like this:
public partial class MyClient
{
partial void ProcessResponse(
HttpClient client,
HttpResponseMessage response)
{
if (!response.IsSuccessStatusCode)
{
// Extract problem details into ReasonPhrase (as workaround)
response.ReasonPhrase = response.Content.ReadAsStringAsync().Result;
}
}
}Consider adding support for:
- ProcessResponseAsync (in addition to the sync ProcessResponse) in order to avoid calling
.Resultwhich blocks the thread and is an antipattern. - Easier access to the response content.
Metadata
Metadata
Assignees
Labels
No labels