C# 403客户端上的错误。executeQuery()
我正在尝试从Office 365站点检索一些信息。我在executeQuery调用中遇到不一致的403错误。这是不规则的,由IISReset解决。请帮忙C# 403客户端上的错误。executeQuery(),c#,wcf,office365,http-status-code-403,C#,Wcf,Office365,Http Status Code 403,我正在尝试从Office 365站点检索一些信息。我在executeQuery调用中遇到不一致的403错误。这是不规则的,由IISReset解决。请帮忙 ClientContext clientContext = new ClientContext(Constants.SP_URL); { SecureString passWord = new SecureString(); foreach (char c
ClientContext clientContext = new ClientContext(Constants.SP_URL);
{
SecureString passWord = new SecureString();
foreach (char c in Constants.SP_SERVICE_PASS.ToCharArray()) passWord.AppendChar(c);
var cred = new SharePointOnlineCredentials(Constants.SP_SERVICE_ACC, passWord); ;
clientContext.Credentials = new SharePointOnlineCredentials(Constants.SP_SERVICE_ACC, passWord);
Web web = clientContext.Web;
string docLibraryName = Constants.SP_PUBLISHED_LIB;
var list = clientContext.Web.Lists.GetByTitle(docLibraryName);
clientContext.Load(list);
**clientContext.ExecuteQuery();**
以下是获取客户端上下文和加载数据所需的内容。这将根据office 365中的SP Online对您进行身份验证。我不知道你怎么说我重置了我的IIS。除非连接到本地SP实例,否则这不适用
private void AutheticateO365(string url, string password, string userName)
{
Context = new ClientContext(url);
var passWord = new SecureString();
foreach (char c in password.ToCharArray()) passWord.AppendChar(c);
Context.Credentials = new SharePointOnlineCredentials(userName, passWord);
var web = Context.Web;
Context.Load(web);
Context.ExecuteQuery();
}