无法使用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("api@XXXX.onmicrosoft.com", 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.