首页 文章

在OneDrive中检索最近文件的WebUrls

提问于
浏览
1

我正在使用以下Graph API调用从OneDrive for Business检索我最近的文件;

https://graph.microsoft.com/v1.0/me/drive/recent

在响应中, driveitem 对象比模式建议的更稀疏;

screenshot of JSON OneDrive response

具体来说,它缺少 webUrl 属性 .

如果我尝试明确请求该属性如下;

https://graph.microsoft.com/v1.0/me/drive/recent?select=webUrl

然后我得到以下回应;

{  
   "@odata.context":"https://graph.microsoft.com/v1.0/$metadata#Collection(driveItem)",
   "value":[  
      {  
         "@odata.type":"#microsoft.graph.driveItem"
      },
      {  
         "@odata.type":"#microsoft.graph.driveItem"
      },
      {  
         "@odata.type":"#microsoft.graph.driveItem"
      },
      {  
         "@odata.type":"#microsoft.graph.driveItem"
      },
      {  
         "@odata.type":"#microsoft.graph.driveItem"
      }
   ]
}

如何从Graph API获取此数据?我已经尝试过后续调用直接使用此调用来获取项目(根据documentation);

https://graph.microsoft.com/v1.0/drives/<remoteItem.driveId>/items/<id>

然而,这似乎总是失败;

{
  "error": {
    "code": "itemNotFound",
    "message": "The resource could not be found.",
    "innerError": {
      "request-id": "a86bdc25-771b-4b90-9c17-942e05bd9ed3",
      "date": "2016-05-22T08:21:57"
    }
  }
}

关于Azure Active Directory权限,我已经注册了一个Native Client应用程序,并且我已经给它了 all Microsoft Graph API委托权限(所有40个) . Overkill我知道,但我只想先让这个工作,然后将删除权限,直到我刚刚得到必要的权限 .

1 回答

  • 0

    您需要添加“Files.Read.All”,“Sites.Read.All”范围,您可以在azure portal中找到它,“读取用户可以访问的所有文件” .

    enter image description here

    有了它,熊令牌转换为
    enter image description here

    没有它,熊牌转换为
    enter image description here

    我没有检查“读取用户可以访问的所有文件”的“itemNotFound”错误,但检查成功 .

相关问题