Skip to content
Discussion options

You must be logged in to vote

To read response headers with Refit, change the method return type so Refit hands you the response, not just the deserialized body. By default Refit returns only the body, so headers are discarded.

Use one of:

  • Task - full raw response, read resp.Headers and resp.Content.Headers yourself.
  • Task<IApiResponse> (or Task<ApiResponse>) - gives you the deserialized body plus .Headers and .ContentHeaders.
[Get("/download")]
Task<HttpResponseMessage> Download();

// or
[Get("/download")]
Task<IApiResponse<Stream>> Download();

Then:

var resp = await api.Download();
var disposition = resp.Content.Headers.ContentDisposition;       // for HttpResponseMessage
// or
var disposition = resp.ContentHeaders?.

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