sharepoint经常显示错误429(请求太多),我们已经采取了以下文章中描述的所有操作,但仍有一些请求被阻止。
我们的方案涉及Word,Excel,Power Point和Outlook的自定义桌面应用程序(加载项),它通过CSOM访问Sharepoint(使用用户的网络凭据),我们已经通过以下方式注册了此加载项" / _布局/ 15 / AppRegNew.aspx"页面并用" NONISV | {我们的组织名称} | {我们的ADDIN NAME} /1.0"来装饰我们的所有请求,如下所述:
https://docs.microsoft.com/en-us/sharepoint/dev/sp-add-ins/register-sharepoint-add-ins
答案 0 :(得分: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
如here所述。祝你好运!