您可以在标题中阅读,我对username参数有疑问。 我总是会收到错误:
System.ArgumentException:'用户名'参数无效。”
所在行:SharePointOnlineCredentials orgIDCredential = new SharePointOnlineCredentials(netcred.UserName, netcred.SecurePassword);
任何想法如何解决?
private static csom.ProjectContext GetContext(string url)
{
csom.ProjectContext context = new csom.ProjectContext(url);
string userName,passWord;
Console.WriteLine("Please enter your username for PWA");
userName = Console.ReadLine();
Console.WriteLine("Please enter your password for PWA");
passWord = Console.ReadLine();
NetworkCredential netcred = new NetworkCredential(userName, passWord);
SharePointOnlineCredentials orgIDCredential = new SharePointOnlineCredentials(netcred.UserName, netcred.SecurePassword);
context.Credentials = orgIDCredential;
return context;
}
答案 0 :(得分:0)
我也遇到了这个错误,解决方法是在使用用户名时不包括域:
NetworkCredential netcred = new NetworkCredential("userName", passWord);
让我知道是否有帮助。