我正在尝试使用此函数从 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.All
或 Sites.ReadWrite.All
权限范围。
根据documentation :
Sites.Read.All
Read items in all site collections
每个列表类型的权限范围:
- SharePoint 列表:
Sites.Read.All
、Sites.ReadWrite.All
- SharePoint 库:
Files.Read.All
、Files.ReadWrite.All
关于c# - Microsoft Graph SDK 和 SharePoint 列表项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49349577/