更新时间:2022-06-07 23:26:08
按照此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
如 查看全文