Skip to content

Commit 05a0750

Browse files
committed
Merge branch 'master' into live
2 parents 7ea3386 + 93f2d93 commit 05a0750

File tree

1 file changed

+6
-21
lines changed

1 file changed

+6
-21
lines changed

docs/general-development/how-to-avoid-getting-throttled-or-blocked-in-sharepoint-online.md

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Avoid getting throttled or blocked in SharePoint Online
33
description: Find out about throttling in SharePoint Online, and learn how to avoid being throttled or blocked. Includes sample client-side object model (CSOM) and REST code you can use to make your task easier.
4-
ms.date: 07/07/2021
4+
ms.date: 05/11/2022
55
ms.prod: sharepoint
66
ms.assetid: 33ed8106-d850-42b1-8d7f-5ba83901149c
77
ms.localizationpriority: high
@@ -183,17 +183,16 @@ HttpWebResponse endpointResponse = (HttpWebResponse)endpointRequest.GetResponse(
183183
Add this extension method in a static class and use `ExecuteQueryWithIncrementalRetry` instead of `ExecuteQuery` to make your code handle throttling requests.
184184

185185
```csharp
186-
public static void ExecuteQueryWithIncrementalRetry(this ClientContext clientContext, int retryCount, int delay)
186+
public static void ExecuteQueryWithIncrementalRetry(this ClientContext clientContext, int retryCount)
187187
{
188188
int retryAttempts = 0;
189-
int backoffInterval = delay;
190189
int retryAfterInterval = 0;
191190
bool retry = false;
192191
ClientRequestWrapper wrapper = null;
193192
if (retryCount <= 0)
193+
{
194194
throw new ArgumentException("Provide a retry count greater than zero.");
195-
if (delay <= 0)
196-
throw new ArgumentException("Provide a delay greater than zero.");
195+
}
197196

198197
// Do while retry attempt is less than retry count
199198
while (retryAttempts < retryCount)
@@ -234,25 +233,11 @@ public static void ExecuteQueryWithIncrementalRetry(this ClientContext clientCon
234233
wrapper = (ClientRequestWrapper)ex.Data["ClientRequest"];
235234
retry = true;
236235

237-
// Determine the retry after value - use the `Retry-After` header when available
238-
string retryAfterHeader = response.GetResponseHeader("Retry-After");
239-
if (!string.IsNullOrEmpty(retryAfterHeader))
240-
{
241-
if (!Int32.TryParse(retryAfterHeader, out retryAfterInterval))
242-
{
243-
retryAfterInterval = backoffInterval;
244-
}
245-
}
246-
else
247-
{
248-
retryAfterInterval = backoffInterval;
249-
}
236+
// Determine the retry after value - use the `Retry-After` header
237+
retryAfterInterval = Int32.Parse(response.GetResponseHeader("Retry-After"));
250238

251239
// Delay for the requested seconds
252240
Thread.Sleep(retryAfterInterval * 1000);
253-
254-
// Increase counters
255-
backoffInterval = backoffInterval * 2;
256241
}
257242
else
258243
{

0 commit comments

Comments
 (0)