microsoft-graph-api - 尝试查询 Microsoft Graph 的 getActivitiesByInterval 路由时出现错误 500
问题描述
我使用 clientCredentials 成功检索了 Microsoft Graph 令牌,但是当我尝试查询 getActivitiesByInterval 路由(对于 SharePoint 网站)时,我收到了 HTTP 500:
"code": "generalException",
"message": "The remote server returned an error: (500) Internal Server Error."
我注册的应用程序在 Microsoft Graph 上具有以下权限(Application)(Files.Read.All、Files.ReadWrite.All、Sites.Read.All、Sites.ReadWrite.All、User.Read.All)。如果我使用从图形资源管理器中检索到的令牌执行完全相同的查询,我会收到带有我要求的内容的 HTTP 200。
我使用的令牌似乎是正确的,因为我可以在没有 HTTP 500 的情况下检索 Microsoft Graph 上的用户。
我用来执行请求的代码如下(它是一个带有 Microsoft Graph 绑定以获取令牌的 Azure 函数):
[FunctionName("SharepointSitesViews")]
public static async Task Run([TimerTrigger("0 */5 * * * *", RunOnStartup = true)]TimerInfo myTimer,
[Token(Identity = TokenIdentityMode.ClientCredentials, IdentityProvider ="AAD", Resource = "https://graph.microsoft.com")] string graphToken,
ILogger log)
{
HttpClient client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", graphToken);
var response = await client.GetAsync("https://graph.microsoft.com/beta/sites/****MySiteId*****/getActivitiesByInterval?startDateTime=2018-09-12T09:59:19.817Z&endDateTime=2018-12-11T00:00:00.000Z&interval=day");
var me = await response.Content.ReadAsStringAsync();
}
带有 URL“ https://graph.microsoft.com/v1.0/users ”的相同代码返回 200。
我还使用 postman 重现了相同的 500 错误:
GET /beta/sites/****MySiteId****/getActivitiesByInterval?startDateTime=2018-09-12T09:59:19.817Z& endDateTime=2018-12-11T00:00:00.000Z& interval=day HTTP/1.1
Host: graph.microsoft.com
Authorization: Bearer *****myToken****
cache-control: no-cache
解决方案
推荐阅读
- javascript - 如何设置onclick验证javascript的条件
- entity-framework - ASP.NET Core Entity Framework 连接字符串超过 1 个登录用户
- python - pytorch中的坐标图像识别
- apache-spark - 将 Spark 作业远程提交到独立集群
- java - 在 Java 开发过程中如何正确绕过 reCAPTCHA
- python - 不知道为什么会这样?
- http - 如果客户端发送连接关闭标头,服务器是否可以与有效负载产生共鸣?
- python-3.x - 我需要创建一个 pyspark UDF,它通过比较从查询中输出一个表
- javascript - 将mysql查询行存储在变量中以供以后在另一个mysql查询中使用
- html - Django ManyToMany 查询,传递给 HTML