尝试查询Microsoft Graph的getActivitiesByInterval路由时出现错误500

时间:2019-01-22 17:35:45

标签: microsoft-graph

我成功使用clientCredentials检索了Microsoft Graph令牌,但是当我尝试查询getActivitiesByInterval路由(对于SharePoint网站)时,我收到了HTTP 500:

    "code": "generalException",
    "message": "The remote server returned an error: (500) Internal Server Error."

我注册的应用程序对Microsoft Graph拥有以下权限(应用程序)(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。

我还使用邮递员重现了同样的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

0 个答案:

没有答案