---
title: Consume result
summary: Convert IHttpRequestResult content and headers into strongly typed values.
status: draft
owner: Framework
last_reviewed: 2026-10-02
library: SAIF.NetCore.HttpClients
reference_type: package
operation_id: OP-05
trigger: A consumer calls GetResult, GetContent, or GetHeaderValue on a returned IHttpRequestResult
---

# Consume result

After [Execute request](execute-request.md) returns an `IHttpRequestResult`, consumers convert its `Content` and `Headers` into strongly typed values using `GetResult<T>`, `GetContent<T>`, and `GetHeaderValue<T>`.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-05 |
| **Trigger** | A consumer calls `GetResult<T>()`/`GetResult<T>(CultureInfo)`, `GetContent<T>()`/`GetContent<T>(CultureInfo)`, or `GetHeaderValue<T>(name)` on an `IHttpRequestResult` |
| **Inputs** | An `IHttpRequestResult` (status, content, headers) and a target type `T`; optional `CultureInfo` |
| **Outputs** | A converted `T` value, `default(T)` (for `GetResult<T>` on an unsuccessful result), or the converted header value |
| **Primary components** | `HttpRequestResult.GetResult<T>`, `HttpRequestResult.GetContent<T>`, `HttpRequestResult.GetHeaderValue<T>`, `HttpJsonClientExtensions.ToReturnType<T>`, `HttpJsonClientExtensions.GetHeaderValue<T>` |
| **Entry point** | `src/SAIF.NetCore.HttpClients/SAIF.NetCore.HttpClients/SAIF.NetCore.HttpClients/HttpJsonClient/HttpRequestResult.cs` |

## Steps

1. **`GetResult<T>()`**: checks `IsSuccessful`.
   - If `false`: return `default(T)` without attempting conversion ([BR-HTTP-18](../business-rules.md#br-http-18-getresult-returns-default-on-failure))
   - If `true`: delegate to `ToReturnType<T>` on `Content` (step 2).
2. **`GetContent<T>()`**: delegates to `ToReturnType<T>` on `Content` regardless of `IsSuccessful` ([BR-HTTP-19](../business-rules.md#br-http-19-content-conversion-trims-quotes-and-honors-culture))
   - If `T` is `string` and the content both starts and ends with `"`: strip exactly that outer quote pair (preserving any inner escaped quotes), then convert the unwrapped text with `Convert.ChangeType` using the supplied (or default) culture.
   - Otherwise, if `T` is a value type or `string`: convert the unmodified content with `Convert.ChangeType` using the supplied (or default) culture — a quoted numeric string such as `"5"` is passed through unquoted only when `T` is `string`, so this path does not unquote it for a numeric `T`.
   - Otherwise: deserialize the unmodified content as JSON using `JsonConvert.DeserializeObject` with the culture passed through the serializer settings.
3. **`GetHeaderValue<T>(name)`**: delegates to the extension method of the same name on `Headers`.
   - Look up `name` case-insensitively using `SingleOrDefault` ([BR-HTTP-20](../business-rules.md#br-http-20-case-insensitive-header-lookup))
   - On failure: if more than one header matches case-insensitively (a case-variant duplicate), the lookup throws.
   - If the match is null, `ConvertHeaderValue` returns `default(T)`.
   - If `T` is `Nullable<U>`, unwrap to the underlying type `U` before conversion.

## Process flow

The following diagram visualizes the three result-consumption paths.

```mermaid
flowchart TD
    Start([Consumer holds IHttpRequestResult]) --> Choice{Which accessor?}
    Choice -->|GetResult&lt;T&gt;| CheckSuccess{IsSuccessful?}
    CheckSuccess -->|No| Default(["Return default(T)"])
    CheckSuccess -->|Yes| Convert["ToReturnType&lt;T&gt;(Content)"]
    Choice -->|GetContent&lt;T&gt;| Convert
    Convert --> StringQuoted{"T is string and content<br>starts/ends with &quot;?"}
    StringQuoted -->|Yes| UnwrapQuotes["Strip outer quote pair<br>(preserve inner escaped quotes)"]
    StringQuoted -->|No| TypeCheck{"Value type or string?"}
    UnwrapQuotes --> ChangeType["Convert.ChangeType(culture)"]
    TypeCheck -->|Yes| ChangeType
    TypeCheck -->|No| Json["JsonConvert.DeserializeObject(culture)"]
    ChangeType --> Done(["Typed value returned"])
    Json --> Done
    Choice -->|GetHeaderValue&lt;T&gt;| Lookup["Case-insensitive SingleOrDefault lookup"]
    Lookup --> Dup{"Case-variant duplicate?"}
    Dup -->|Yes| Throw(["Throws"])
    Dup -->|No| Null{"Match is null?"}
    Null -->|Yes| DefaultHeader(["Return default(T)"])
    Null -->|No| UnwrapHeader["Unwrap Nullable&lt;T&gt; if needed, convert"]
    UnwrapHeader --> DoneHeader(["Typed value returned"])
```

## Failure and edge-case behavior

- `GetResult<T>` never attempts conversion for an unsuccessful response, even if `Content` contains valid data for `T`; use `GetContent<T>` to force conversion regardless of status ([BR-HTTP-18](../business-rules.md#br-http-18-getresult-returns-default-on-failure))
- A case-variant duplicate header name (for example both `Content-Type` and `content-type` present) causes `GetHeaderValue<T>` to throw rather than silently pick one.
- Content that is not valid JSON for a non-value-type `T` surfaces a `JsonConvert` deserialization exception to the caller.

## Related documentation
- [Operations and processes](../operations-processes.md)
- [Business rules](../business-rules.md)

## Sources
- `src/SAIF.NetCore.HttpClients/SAIF.NetCore.HttpClients/SAIF.NetCore.HttpClients/HttpJsonClient/HttpRequestResult.cs`
- `src/SAIF.NetCore.HttpClients/SAIF.NetCore.HttpClients/SAIF.NetCore.HttpClients/HttpJsonClient/HttpJsonClientExtensions.cs`
