我正在尝试使用此功能从SharePoint Projectsite中的任务列表中检索所有项目:
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/ $元数据#网站( 'xxxxxxxxxx.com%2Cde7be133-babf-4bc9-8e52-857657f8fdd6%2C379cb706-d430-4dfc-8347-f2c8bc92a38c')/列表(” eca2429f-44b7-4d68-af81-f5e56fece3ab')/项目”, “值”:[]}
我不明白为什么回答是空的。在Graph Explorer中,它返回数据。有人可以解释一下吗?
由于
答案 0 :(得分:1)
由于您查询SharePoint List Items
,因此需要指定Sites.Read.All
或Sites.ReadWrite.All
权限范围。
Sites.Read.All
阅读所有网站集中的项目
每个列表类型的权限范围:
Sites.Read.All
,Sites.ReadWrite.All
Files.Read.All
,Files.ReadWrite.All