Skip to content

Results

Run the complete page example.

After sending a request, your app needs to decide what to do with the reply. Sometimes you only need a person or a list of records. Other calls need the status and headers, an explanation of a failure, or a way to process items as they arrive.

The return type on your Refit method controls what your caller receives. Start with a task returning the deserialized body for an ordinary request. Refit reports an unsuccessful HTTP response, a transport failure, or a deserialization failure as an exception for that form.

Choose ApiResponse<T> or IApiResponse<T> when you want to inspect the status, headers, body, and error on the returned value. Dispose an ApiResponse<T> after you finish with it. Use IObservable<T> when the request result should be delivered through a subscription. It represents one request result. Use IAsyncEnumerable<T> when one response contains a stream of items that your code should read with await foreach.

These pages help you choose a return form and handle its result.

PageWhat it covers
Return typesAwaiting one result, querying a reply, and checking a response wrapper.
Streaming repliesReading several items with await foreach.
Response detailsStatus, content, headers, transport failures and success guards.
Error bodiesTyped error JSON, problem details and custom failure handling.
Return adaptersCustom wrappers and matching generic return types.