Skip to content

Commit da45a6a

Browse files
docs: add raw responses to readme
1 parent 94fda3a commit da45a6a

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,29 @@ To send a request to the Orb API, build an instance of some `Params` class and p
103103

104104
For example, `client.Customers.Create` should be called with an instance of `CustomerCreateParams`, and it will return an instance of `Task<Customer>`.
105105

106+
## Raw responses
107+
108+
The SDK defines methods that deserialize responses into instances of C# classes. However, these methods don't provide access to the response headers, status code, or the raw response body.
109+
110+
To access this data, prefix any HTTP method call on a client or service with `WithRawResponse`:
111+
112+
```csharp
113+
var response = await client.WithRawResponse.Customers.Create(parameters);
114+
var statusCode = response.Message.StatusCode;
115+
var headers = response.Message.Headers;
116+
```
117+
118+
For non-streaming responses, you can deserialize the response into an instance of a C# class if needed:
119+
120+
```csharp
121+
using System;
122+
using Orb.Models.Customers;
123+
124+
var response = await client.WithRawResponse.Customers.Create(parameters);
125+
Customer deserialized = await response.Deserialize();
126+
Console.WriteLine(deserialized);
127+
```
128+
106129
## Error handling
107130

108131
The SDK throws custom unchecked exception types:

0 commit comments

Comments
 (0)