<titledata-react-helmet="true">Retry Handling | SpotifyAPI-NET</title><metadata-react-helmet="true"name="docsearch:version"content="next"><metadata-react-helmet="true"name="twitter:card"content="summary_large_image"><metadata-react-helmet="true"property="og:title"content="Retry Handling | SpotifyAPI-NET"><metadata-react-helmet="true"name="description"content="In Error Handling we already found out that requests can fail. We provide a way to automatically retry requests via retry handlers. Note, by default no retries are performed."><metadata-react-helmet="true"property="og:description"content="In Error Handling we already found out that requests can fail. We provide a way to automatically retry requests via retry handlers. Note, by default no retries are performed."><metadata-react-helmet="true"property="og:url"content="https://johnnycrazy.github.io/SpotifyAPI-NET/docs/next/retry_handling"><linkdata-react-helmet="true"rel="shortcut icon"href="/SpotifyAPI-NET/img/favicon.ico"><linkdata-react-helmet="true"rel="canonical"href="https://johnnycrazy.github.io/SpotifyAPI-NET/docs/next/retry_handling"><linkrel="stylesheet"href="/SpotifyAPI-NET/styles.8a053330.css">
</span></div><divclass="token-line"style="color:#bfc7d5"><spanclass="token plain"> // use retry as often as you want, make sure to return a response</span></div><divclass="token-line"style="color:#bfc7d5"><spanclass="token plain"> }</span></div><divclass="token-line"style="color:#bfc7d5"><spanclass="token plain">}</span></div></div></div></div></div><h2><aaria-hidden="true"tabindex="-1"class="anchor enhancedAnchor_ZqCz"id="simpleretryhandler"></a>SimpleRetryHandler<aaria-hidden="true"tabindex="-1"class="hash-link"href="#simpleretryhandler"title="Direct link to heading">#</a></h2><p>A <code>SimpleRetryHandler</code> is included, which contains the following retry logic:</p><ul><li>Retries the (configurable) status codes: 500, 502, 503 and 429</li><li><code>RetryAfter</code> - specifies the delay between retried calls</li><li><code>RetryTimes</code> - specifies the maxiumum amount of performed retries per call</li><li><code>TooManyRequestsConsumesARetry</code> - Whether a failure of type "Too Many Requests" should use up one of the retry attempts.</li></ul><divclass="mdxCodeBlock_iHAB"><divclass="codeBlockContent_32p_"><buttontype="button"aria-label="Copy code to clipboard"class="copyButton_1BYj">Copy</button><divtabindex="0"class="prism-code language-csharp codeBlock_19pQ"><divclass="codeBlockLines_2n9r"style="color:#bfc7d5;background-color:#292d3e"><divclass="token-line"style="color:#bfc7d5"><spanclass="token plain">var config = SpotifyClientConfig</span></div><divclass="token-line"style="color:#bfc7d5"><spanclass="token plain"> .CreateDefault()</span></div><divclass="token-line"style="color:#bfc7d5"><spanclass="token plain"> .WithRetryHandler(new SimpleRetryHandler() { RetryAfter = TimeSpan.FromSeconds(1) });</span></div><divclass="token-line"style="color:#bfc7d5"><spanclass="token plain"style="display:inline-block">