【问题标题】:404 file not found error when using microsoft graph api使用 microsoft graph api 时找不到 404 文件错误
【发布时间】:2016-07-07 03:46:08
【问题描述】:

我在调用图形 api 时遇到以下错误,https://graph.microsoft.com/v1.0/me/drive/root:/foldername 使用通过开放 id 连接协议获得的访问令牌,但如果我使用相同的令牌来访问 https://graph.microsoft.com/v1.0/me API,它可以工作,我所在的文件夹搜索确实存在于一个驱动器上,但我仍然收到此错误,当我在一段时间后运行相同的代码时,我发现它工作正常。可能是什么问题。即使对于这个 api https://graph.microsoft.com/v1.0/me/drive/root/children,我也会遇到以下错误。

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

【问题讨论】:

    标签: microsoft-graph-api


    【解决方案1】:

    如果您最终使用纯应用授权:

    this answer 中所述,目前不支持仅应用授权通过 Microsoft Graph API 访问 OneDrive for Business,并将引发 404 FILE NOT FOUND 异常。

    为了解决这个问题,我使用了passwordgrant_type 流来请求令牌:

    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
    

    【讨论】:

      【解决方案2】:

      当用户没有 Office 365 / OneDrive 或拥有但尚未初始化 OneDrive(即导航到 https://[domain]-my.sharepoint.com/personal/)时,会发生此 “404 FILE NOT FOUND” 错误。

      用户获取O365/OneDrive并初始化后,应该可以成功查询到https://graph.microsoft.com/v1.0/me/drive/root/children

      你也应该可以查询https://graph.microsoft.com/v1.0/me/drive/root:/foldername

      如果您确实遇到了未找到文件夹的合法案例,您会收到以下错误消息:

      {
          "error": {
              "code": "itemNotFound",
              "message": "The resource could not be found.",
              "innerError": {
                  "request-id": "1ce2bd8d-a88f-42ae-affd-ee90f3c1d4fb",
                  "date": "2016-07-11T03:17:25"
              }
          }
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2023-03-14
        • 2020-08-03
        • 2018-01-24
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多