Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Avoid getting throttled or blocked in SharePoint Online


Another great day!

I’ve some Azure App Service and Azure Web Job which, using Sharepoint CSOM or calling the SharePoint REST API, perform a lot of operation (batch or real-time) on SharePoint Online data.

My jobs are running since some year without any problem.
Yesterday (6 feb 2018) some of my artifacts crash unexpectedly with a strange error:

System.Net.WebException: The remote server returned an error: (429).
TOO MANY REQUESTS

Then I found a nice article that explains how avoid this error communicating with SharePoint Online
https://docs.microsoft.com/en-us/sharepoint/dev/general-development/how-to-avoid-getting-throttled-or-blocked-in-sharepoint-online

In short words you must tell to SharePoint who you are, setting the request UserAgent header with a string like this:

NONISV|CompanyName|AppName/Version

Type
User Agent
Description
ISV Application
ISV|CompanyName|AppName/Version
Identify as ISV and include Company Name, App Name Separated by a pipe character and then adding Version number separated with a slash character
Enterprise application
NONISV|CompanyName|AppName/Version
Identify as NONISV and include Company Name, App Name separated by a pipe character and then adding Version number separated with a slash character

In my case, this is an Enterprise application and I had to set the UserAgent with a string like this for every call to SharePoint services.

NONISV|zSiS|MyService/1.0

Some of my services works using SharePoint CSOM, other, latest, the SharePoint REST API using HttpClient: here the 2 way to set this parameter for both my cases.

CSOM

context.ExecutingWebRequest += delegate (object sender, WebRequestEventArgs e)
            {
                e.WebRequestExecutor.WebRequest.UserAgent = "NONISV|zSiS|MyService01/1.0";
            };

HTTPClient

client.DefaultRequestHeaders.Add("User-Agent","NONISV|zSiS|MyService02/1.0");




This post first appeared on ZSvipullo, please read the originial post: here

Share the post

Avoid getting throttled or blocked in SharePoint Online

×

Subscribe to Zsvipullo

Get updates delivered right to your inbox!

Thank you for your subscription

×