Skip to content
Discussion options

You must be logged in to vote

ReasonPhrase is set by your server, not by Refit. Refit just surfaces whatever came back on the wire.

Two parts:

  1. Server side: set the reason phrase on the response. In ASP.NET Core minimal/MVC you can do:
httpContext.Features.Get<IHttpResponseFeature>()!.ReasonPhrase = result.Error;

Note: ReasonPhrase only exists in HTTP/1.x. Over HTTP/2 and HTTP/3 it is gone, so do not rely on it for transporting error detail. Prefer putting the error in the response body (for example a ProblemDetails or your FluentResults payload) and returning a 4xx status.

  1. Client side with Refit: return ApiResponse<T> (or catch ApiException) and read it:
[Post("/things")]
Task<ApiResponse<MyResult>> CreateThing([Body

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by glennawatson
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants