【问题标题】:403 error on Client.executeQuery()Client.executeQuery() 上的 403 错误
【发布时间】:2015-12-21 13:27:17
【问题描述】:

我正在尝试从 Office 365 网站检索一些信息。我在 executeQuery 调用中收到不一致的 403 错误。这种情况不规律地发生,由 IISReset 解决。请帮忙。

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();**

【问题讨论】:

    标签: c# wcf office365 http-status-code-403


    【解决方案1】:

    这是您获取客户端上下文和加载数据所需的内容。这将针对 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();
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-21
      • 2013-06-26
      • 1970-01-01
      • 2016-12-24
      • 1970-01-01
      • 2017-08-06
      • 1970-01-01
      相关资源
      最近更新 更多