Microsoft Graph下载文件内容返回404

时间:2016-11-02 19:25:35

标签: sharepoint office365 microsoft-graph onedrive

我尝试使用Grpah API下载文件。

使用API​​浏览器测试, https://graph.microsoft.io/en-us/graph-explorer#

执行以下请求,获取文件/文件夹项目信息列表

https://graph.microsoft.com/v1.0/me/drive/root/children

对于其中一个文件项,我能够获取项目信息。

https://graph.microsoft.com/beta/me/drive/items/_an_item_id

但是以下返回HTTP 404。

https://graph.microsoft.com/beta/me/drive/items/_an_item_id/content

这种症状的原因是什么?

1 个答案:

答案 0 :(得分:1)

不支持通过Graph Explorerprivate Handler Download_taskHandler = new Handler(); Download_taskHandler.postDelayed(Download_task, 0); 端点执行请求。

通过Grath Explorer发送到https://graph.microsoft.com/beta/me/drive/items/<itemid>/content端点的请求以preflight request发布。服务器以https://graph.microsoft.com/beta/me/drive/items/<itemid>/content回复,但由于CORS behavior,不允许重定向到预检请求。

以下是有关如何下载文件的解决方法

以下驱动器项资源请求:

302-Redirect

返回https://graph.microsoft.com/beta/me/drive/items/<itemId> 注释,其中包含文件资源的实际链接。

检索到驱动器项资源后,执行另一个来自@microsoft.graph.downloadUrl的URL的GET请求以返回实际文件。

相关问题