我正在尝试使用网站url在Online SharePoint上创建一个文件夹https://example.sharepoint.com/MySite
我真的不关心SharePoint列表,但我找不到任何有关SharePoint API的信息,因为它向消费者隐藏了此实施细节,也找不到能够很好地预测我的需求以告诉我需要做什么的任何文档,所以我很难使用列表。
目前,我只想简单地列出我网站上存在的任何列表。我的网站有一些极简主义的内容,所以我希望在一个所有东西都有列表的世界里,应该有一些列表,我应该能够以某种方式列出它们。
我有以下代码:
using (ClientContext context = _authenticationManager.GetContext())
{
Web web = context.Web;
context.Load(web.Lists, lists => lists.Include(list => list.Title, list => list.Id));
context.ExecuteQuery();
foreach (List list in web.Lists)
{
_logger.LogInformation(list.Title);
}
}
我已经能够使用调试器和控制台来确认AuthenticationManager正在成功生成身份验证令牌。
当代码执行时,context.ExecuteQuery();
会导致以下错误:
[1:49:48 INF]已成功为用户请求新的访问令牌资源example.sharepoint.comsomeuser@somemail.foo<s: SharepointOrderContractExtractor.Clients.AuthenticationManager>[1:49:48 ERR]执行请求时发生未处理的异常<s: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware>System.Net.WebException:远程服务器返回错误:(404)找不到。位于System.Net.HttpWebRequest.GetResponse()位于Microsoft.SharePoint.Client.SWebRequestExecutor.Execute()位于Microsoft.SharePoint.ClientRequest.ExecuteQueryToServer(ChunkStringBuilder-sb)位于Microsoft.SharePoint.Client.ClientRequest.ExecuteQuery()位于Microsoft.SharePoint.Client.ClientRuntimeContext.ExecuteQuery()位于Microsoft.SharePoint.Client.ClientContext.ExecuteQuery()位于C:\projects\SharePointOrderContractExtractor\SharePointOrderContractExtractor\Clients\Sharepoint\Client.cs:line 34中的SharePointOrderContractExtractor.Clients.Client.CreateFolder(字符串文件夹名称)位于C:\projects\SharePointOrderContractExtractor\SharepointOrderExtractor\Services\SharePointService.CreateDestination(列出
1 orderNumbers) in C:projectsSharepointOrderContractExtractorSharepointOrderContractExtractorServicesSharepointService.cs:line 128 at SharePointOrderContractExtractor.Services.SharePointService.CollectForAsync(List
1个订单号)中位于C:\projects\SharePointOrderContractExtractor\Services\SharePointService.FetchContractsAsync(FileUploadModel uploadModel)位于C:\projects\SharePointOrderContractExtractor\SharePointOrderContractExtractor\Controllers\V1_0\SharePointController.cs:line 48中的SharePointOrderContractExtractor.Controllers.V1_SharePointController.Upload(FileUploadModel uploadModel)位于Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfIActionResultExecutor.Execute(IActionResultTypeMapper映射程序、ObjectMethodExecutor执行程序、Object控制器、Object[]参数)位于Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g_Logged|12_1(ControllerActionInvoker调用程序)位于Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g_Await|10_0(ControllerActionInvoker调用程序,任务lastTask,状态next,作用域范围,对象状态,布尔值isCompleted)位于Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed上下文)在Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State&Next,Scope&Scope,Object&State,Boolean&isCompleted)位于Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g_Await|13_0(ControllerActionInvoker调用程序,任务lastTask,状态next,作用域范围,对象状态,布尔值isCompleted)位于Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g_Await|19_0(ResourceInvoker调用程序,Task lastTask,State next,Scope Scope,Object State,Boolean isCompleted)位于Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g_Logged|17_1(资源调用程序调用程序)位于Microsoft.AspNetCore.Routing.EndpointMiddleware.g_AwaitRequestTask|6_0(端点,任务请求任务,ILogger记录器)位于Swashfleck.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext HttpContext,ISwagerProvider swaggerProvider)位于Microsoft.AspNetCore.Authorization.AuthenticationMiddleware.IInvoke(HttpContext上下文)位于Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.IInvoke(HttpContext上下文)位于Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.IInvoke(HttpContexthttpContext)位于Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.IInvoke(HttpContext上下文)
我遗漏了什么和/或做错了什么?我该如何更正?
感谢@arconaut在评论中提出的问题:
身份验证管理器似乎只使用域,而不是完整的URL来进行身份验证。
当我的网站URL设置为https://example.sharepoint.com/MySite,应该是https://example.sharepoint.com/sites/MySite.
(我想我在尝试遵循一些可能与我的Salesforce版本不匹配的文档时,从配置中删除了"站点"。)