it is better to use ExecuteQueryRetry from OfficeDevPnP Core which was designed to avoid throttling issues.
The remote server returned an error: (429).
Hello! I have 3 services in my company. All services work with one service account and sometime I catch error:
The remote server returned an error: (429). Stack: at System.Net.HttpWebRequest.GetResponse() at Microsoft.SharePoint.Client.SPWebRequestExecutor.Execute() at Microsoft.SharePoint.Client.ClientRequest.ExecuteQueryToServer(ChunkStringBuilder sb) at Microsoft.SharePoint.Client.ClientContext.ExecuteQuery() at DD.ProjectApproval.Model.SPListItemExtensions.GetFieldUserValueNew(ListItem item, String fieldName, ClientContext clientContext).
I read microsoft recomendations, but I undurstend about
e.WebRequestExecutor.WebRequest.UserAgent = "NONISV|Contoso|GovernanceCheck/1.0";
GovernanceCheck - Enterprice app name, Do I only have to register new app in Enterprice App or need to configure it else?
Contoso -name of Company, where I can find name in Azure?
- 0 -versions of app, where I can find versions?
And I read about "ExecuteQueryWithIncrementalRetry extension method", Is method better tnan ExecuteQueryRetry in OfficeDevPnP.Core, Version=2.24.1803.0?
Thanks!
14 answers
Sort by: Most helpful
-
-
Trevor Seward 11,706 Reputation points
2021-03-17T17:56:20.06+00:00 You should switch over to use Client ID + Certificate/Secret from username/password. This will be more secure and should also help (but may not eliminate, depending on what you're doing, stamp health, etc.) avoid 429 responses.
-
Jerryzy 10,571 Reputation points
2021-03-18T02:24:02.56+00:00 Hi @Nerobov Andrey ,
Please refer the official document below to use e.WebRequestExecutor.WebRequest.UserAgent for avoid throttling:
Avoid getting throttled or blocked in SharePoint Online
Also you can build a extension method ExecuteQueryWithIncrementalRetry also like official document for handling 429 throttling issue.
Thanks
Best Regards
If an Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread. -
Nerobov Andrey 96 Reputation points
2021-03-18T07:24:24.41+00:00 @Jerryzy-MSFT thanks. but I am already it : using (var ctx = new ClientContext(new Uri(Consts.PortalUrl, UriKind.Absolute)))
{
log.Info(Environment.UserDomainName);
log.Info(Consts.getMailIP);
var creds = new NetworkCredential(Autorization.UserEmail, Autorization.Password);
ctx.Credentials = new SharePointOnlineCredentials(creds.UserName, creds.SecurePassword);
ctx.ExecutingWebRequest += delegate (object sender, WebRequestEventArgs e)
{
e.WebRequestExecutor.WebRequest.UserAgent = $"NONISV|Digdes|{Consts.AppSettings.Name}/1.0";
};
}
but it don't help me. Probably, is UserAgent wrong? How check it? -
Jerryzy 10,571 Reputation points
2021-03-18T07:45:16.84+00:00 I used the UserAgent "NONISV|Contoso|GovernanceCheck/1.0", it's working per the test:
But as you have met the 429 error in your environment, you should firstly wait for 429 recovery, then use the UserAgent for avoiding the issue.