本文介绍了无法使用WebAPI中的CSOM在线连接到SharePoint的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用CSOM在线连接到SharePoint以在任务列表上执行CRUD。但是以下实现在控制台应用程序上工作正常但不是WebAPI。

I have tried to connect to SharePoint online using CSOM to perform CRUD on tasklist. However the following implementation working fine on console application but not WebAPI.

ClientContext cc = new ClientContext("https://XXXX.sharepoint.com");
SecureString pass = new SecureString();

foreach (char c in "XXXX".ToCharArray();
    pass.AppendChar(c);

cc.Credentials = new SharePointOnlineCredentials("[email protected]", pass);
cc.Load(cc.Web);
cc.ExecuteQuery();

我输了相同的代码在WebAPI中,它总是抛出异常"无法连接到远程服务器"。

I put the same code in WebAPI and it always throws exception "Cannot connect to remote server".

我已经检查了这个  文章&b $ b它表示它与权限和应用程序池标识有关,你们能否提供更多有关如何解决此问题的详细信息因为要求CRUD操作需要处于API级别。

I have checked this article and it said it has something to do with Privileges and Application Pool Identity, can you guys provide more details on how to resolve this issue as it is requirement that the CRUD operations needs to be at API level.

目前,我使用MS Visual Studio进行开发,而WebAPI在运行时在IIS express下执行。如果是与权限和应用程序池标识有关,我如何在IIS express下查看。

Currently, i doing development using MS Visual Studio and the WebAPI is executed under IIS express on run time. If it is something to do with Privileges and Application Pool Identity, how could i check under IIS express.

谢谢。

推荐答案

Ple ase检查与WEBAPI相关的IIS应用程序池帐户,并将其更改为SharePoint帐户。

Please check your WEBAPI related IIS application pool account, and change it to SharePoint account.


这篇关于无法使用WebAPI中的CSOM在线连接到SharePoint的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 14:38