The remote server returned an error: (429).

Nerobov Andrey 96 Reputation points
2021-03-17T14:03:04.743+00:00

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?

  1. 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!
SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
9,617 questions
0 comments No comments
{count} votes

14 answers

Sort by: Most helpful
  1. sadomovalex 3,626 Reputation points
    2021-03-17T14:49:49.1+00:00

    it is better to use ExecuteQueryRetry from OfficeDevPnP Core which was designed to avoid throttling issues.

    1 person found this answer helpful.

  2. Trevor Seward 11,681 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.

    0 comments No comments

  3. Jerryzy 10,566 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:

    78936-snipaste-2021-03-18-10-00-49.png

    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.

    0 comments No comments

  4. 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?

    0 comments No comments

  5. Jerryzy 10,566 Reputation points
    2021-03-18T07:45:16.84+00:00

    @Nerobov Andrey ,

    I used the UserAgent "NONISV|Contoso|GovernanceCheck/1.0", it's working per the test:

    79064-snipaste-2021-03-18-15-38-18.png

    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.

    0 comments No comments