.NET SDK errors
A non-success response is thrown as a generated ErrorEnvelope, not returned as null. A rejected call cannot
be mistaken for a successful one.
using DiligenceID.Management.Models;
try
{
await management.Management.Issuers[issuerId].PatchAsync(
update,
c =>
{
c.QueryParameters.ApiVersion = ApiVersion;
c.Headers.Add("If-Match", etag);
});
}
catch (ErrorEnvelope error)
{
var code = error.Error?.Code;
var requestId = error.Error?.InnerError?.RequestId;
logger.LogWarning("DiligenceID rejected the update. code={Code} requestId={RequestId}", code, requestId);
if (code == "precondition_failed")
{
// Re-read, re-apply, retry.
}
}
Branch on Code
Not on Message. Code is the stable contract; Message is for humans and may be reworded.
The thrown exception's own Message does not repeat the code — read error.Error.Code from the caught
object.
Log the request id
error.Error.InnerError.RequestId is the server's identifier for the failed request. It is also on the
response as x-ms-request-id. Log it on every failure; a support request without it is largely unanswerable.
What to retry
| Code / status | Retry |
|---|---|
429, 5xx |
Yes, with backoff |
precondition_failed |
Yes, after re-reading |
400, 401, 403, 404, 409 |
No. Retrying unchanged fails identically |
A retry of a mutating call needs the same Idempotency-Key as the original attempt.
No built-in retry policy
Supply your own HttpClient with the handlers your application already uses. See
authentication.