0

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

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”修饰我们的所有请求,如下所述:

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

4

1 回答 1

0

请按照此 Microsoft 文章中的说明进行操作:

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

注册外接程序后,在创建 SharePoint 上下文时执行此操作(使用 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 应该类似于:

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

如此处所述。祝你好运!

于 2019-06-20T21:39:30.780 回答