You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TimCodes.NET edited this page Dec 1, 2023
·
1 revision
Sometimes APIs fail, or can be rate-limited etc. You can specify how your API client should retry in different response scenarios by implementing an IRetryPolicy:
This allows you to inspect an IApiResponse and the number of attempts already tried, and return whether or not the request should be retried.
Just before it is retried, your OnBeforeRetryAsync method will be called, allowing you to manipulate the request or response. In the case of the OpenIdRetryPolicy, it clears the access token from the cache when an Unauthorized response is received.
You could potentially use this feature to implement an exponential backoff retry policy.
To assign a retry policy, either use the ApiClient's DefaultRetryPolicies or the IApiRequests RetryPolicies.