c# - Microsoft Graph SDK 和 SharePoint 列表项

标签 c# sharepoint sdk microsoft-graph-api

我正在尝试使用此函数从 SharePoint 项目网站的任务列表中检索所有项目:

    public async Task<string> GetTasks(GraphServiceClient graphClient, string siteId, string listId)
    {
        string requestUrl = "https://graph.microsoft.com/v1.0/sites/" + siteId + "/lists/" + listId + "/items?expand=fields";

        HttpRequestMessage hrm = new HttpRequestMessage(HttpMethod.Get, requestUrl);

        await graphClient.AuthenticationProvider.AuthenticateRequestAsync(hrm);

        HttpResponseMessage response = await graphClient.HttpProvider.SendAsync(hrm);

        if (response.IsSuccessStatusCode)
        {
            string content = await response.Content.ReadAsStringAsync();
            return content;
        }
        else
            throw new ServiceException(
                new Error
                {
                    Code = response.StatusCode.ToString(),
                    Message = await response.Content.ReadAsStringAsync()
                });
    }

但响应内容为空:

@odata.context":"https://graph.microsoft.com/v1.0/ $metadata#sites('xxxxxxxxxx.com%2Cde7be133-babf-4bc9-8e52-857657f8fdd6%2C379cb706-d430-4dfc-8347-f2c8bc92a38c')/列表('eca2429f-44b7-4d68-af81-f5e56fece3ab ')/项目", “值”:[]}

我不明白为什么回复是空的。在 Graph Explorer 中,它返回数据。有人能解释一下吗?

谢谢

最佳答案

由于您查询 SharePoint List Items,因此需要指定 Sites.Read.AllSites.ReadWrite.All 权限范围。

根据documentation :

Sites.Read.All Read items in all site collections

每个列表类型的权限范围:

  • SharePoint 列表:Sites.Read.AllSites.ReadWrite.All
  • SharePoint 库:Files.Read.AllFiles.ReadWrite.All

关于c# - Microsoft Graph SDK 和 SharePoint 列表项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49349577/

相关文章:

c# - 取消后如何开始任务

c# - APNS APPLE C# sslstream 响应

visual-studio - WSPBuilder 中的不同范围有什么作用?

.net - 持久共享点 EditorPart 设置

hadoop - 无法在Windows 7 64位中构建hadoop v2.7.1,出现错误:C编译器标识未知,CXX编译器标识未知

c# - 如何使用 jquery 获取 DotNetNuke ModuleID?

c# - 在 DAL 中使用单例模式的优缺点

asp.net - 在 SharePoint 和 ASP.Net Web 应用程序之间共享 Windows 身份验证

ios - 为什么我不能使用 NSMutableArray 添加 UILabel?

java - 在gradle中的这一行编译 'com.batch.android:batch-sdk:1.5+'错误?