如何解决 Sharepoint CSOM HTTP 请求错误 429? [英] How to solve Sharepoint CSOM HTTP Request Error 429?

查看:28
本文介绍了如何解决 Sharepoint CSOM HTTP 请求错误 429?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

sharepoint 经常显示错误 429(请求过多),我们已经采取了下面文章中描述的所有操作,但仍有一些请求被阻止.

The sharepoint often displays error 429 (Too many requests) and we have already taken all the actions described in the article below, but some requests continue to be blocked.

https://docs.microsoft.com/en-us/sharepoint/dev/general-development/how-to-avoid-getting-throttled-or-blocked-in-sharepoint-online

我们的方案涉及用于 Word、Excel、Power Point 和 Outlook 的自定义桌面应用程序(加载项),该应用程序通过 CSOM(使用用户的网络凭据)访问 Sharepoint,我们已经通过/_layouts/15/AppRegNew.aspx"页面,并使用NONISV|{OUR ORGANIZATION NAME}|{OUR ADDIN NAME}/1.0"修饰我们的所有请求,如下所述:

Our scenario involves a customized desktop application (add-in) for Word, Excel, Power Point and Outlook that accesses the Sharepoint through CSOM (with user's network credentials) and we already registered this Add-in through the "/_layouts/15/AppRegNew.aspx" page and decorated all of our requests with "NONISV|{OUR ORGANIZATION NAME}|{OUR ADDIN NAME}/1.0 ", as described in:

https://docs.microsoft.com/en-us/sharepoint/dev/sp-add-ins/register-sharepoint-add-ins

推荐答案

按照这篇 Microsoft 文章中的说明进行操作:

Follow the instructions in this Microsoft article:

https://docs.microsoft.com/en-us/sharepoint/dev/sp-add-ins/register-sharepoint-add-ins

注册加载项后,在创建 SharePoint 上下文(使用 CSOM)时执行此操作:

When you have your Add-In registered, do this when you are creating SharePoint Context (using CSOM):

    private void Initialize()
    {
        this.SPCurrentContext = new ClientContext(this.Url);

        if (string.IsNullOrWhiteSpace(this.Domain))
        {
            this.SPCurrentContext.Credentials = new SharePointOnlineCredentials(this.User, ParseToSecureString(this.Password));
        }
        else
        {
            this.SPCurrentContext.Credentials = new NetworkCredential(this.User, ParseToSecureString(this.Password), this.Domain);
        }

        this.RetryCount = Properties.Settings.Default.DefaultRetryCount;
        this.RetryDelay = Properties.Settings.Default.DefaultRetryDelay;
        this.NONISV = Properties.Settings.Default.ClientAppNONISV;

        this.SPCurrentContext.ExecutingWebRequest += delegate (object sender, WebRequestEventArgs e)
        {
            e.WebRequestExecutor.WebRequest.UserAgent = this.NONISV; // This is the TRICK!!!
        };
    }

用作用户代理 HTTP 标头的 NONISV 应该类似于:

The NONISV used as User-Agent HTTP Header should be something like:

NONISV|{您的公司名称}|{您的加载项名称}/1.0

NONISV|{Your Company Name}|{Your Add-In Name}/1.0

此处.祝你好运!

这篇关于如何解决 Sharepoint CSOM HTTP 请求错误 429?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆