C#
Errors
Handle .NET API failures and inspect raw HTTP responses
Overview
This guide explains how to handle errors returned by the Insion SDK and inspect response details when troubleshooting failed requests.
Handle errors
API failures throw InsionClientApiException; other SDK failures derive from InsionClientException.
try
{
await client.ModerateARecordAsync(request);
}
catch (InsionClientApiException error)
{
Console.Error.WriteLine($"{error.StatusCode}: {error.Body}");
Console.Error.WriteLine(error.RawResponse?.Url);
throw;
}Inspect raw responses
Each operation returns WithRawResponseTask<T>. Normal awaiting yields T; call WithRawResponse() when you need status, URL, or headers.
var response = await client.ListRecordsAsync(new GetApiV1RecordsRequest { Limit = 20 }).WithRawResponse();
Console.WriteLine(response.RawResponse.StatusCode);
Console.WriteLine(response.Data.HasMore);How is this guide?