使用Microsoft图形API时出现404文件未找到错误 [英] 404 file not found error when using microsoft graph api

查看:224
本文介绍了使用Microsoft图形API时出现404文件未找到错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

调用图形API https:时出现以下错误: //graph.microsoft.com/v1.0/me/drive/root:/foldername 使用通过开放ID连接协议获取的访问令牌,但是如果我使用相同的令牌访问 https://graph.microsoft.com/v1.0 /me/drive/root/children 我遇到以下错误.

I am getting following error when calling the graph api, https://graph.microsoft.com/v1.0/me/drive/root:/foldername using the access token got through open id connect protocol, but if i use same token to get to https://graph.microsoft.com/v1.0/me API it works, and the folder which i am searching is really exist on one drive for buisness but still i am getting this error, when i run same code after some time, i found that it works fine. what could be the issue. even for this api https://graph.microsoft.com/v1.0/me/drive/root/children i get following error.

    {
  "error": {
    "code": "UnknownError",
    "message": "404 FILE NOT FOUND",
    "innerError": {
      "request-id": "d7cdf434-ead1-445d-b2be-f269a82027eb",
      "date": "2016-07-07T03:38:47"
    }
  }
}

推荐答案

如果您最终使用仅应用程序授权:

In case you end up here using app-only authorization:

此答案中所述,目前不支持仅应用程序授权才能通过Microsoft Graph API和Microsoft Graph访问OneDrive for Business.会抛出404 FILE NOT FOUND异常.

As mentioned in this answer App-only authorization is currently not supported for accessing OneDrive for Business through Microsoft Graph API and will throw 404 FILE NOT FOUND exceptions.

为解决此问题,我使用了password grant_type流来请求令牌:

To solve this I used the password grant_type flow to request the token:

POST https://login.microsoftonline.com/{tenantId}.onmicrosoft.com/oauth2/token
Content-Type: application/x-www-form-urlencoded

grant_type=password
&username=<username>
&password=<password>
&client_id=<clientId>
&client_secret=<clientSecret>
&resource=https://graph.microsoft.com

这篇关于使用Microsoft图形API时出现404文件未找到错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆