Microsoft Graph下载文件内容返回404 [英] Microsoft Graph download file content returns 404

查看:97
本文介绍了Microsoft Graph下载文件内容返回404的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I tried to download a file with Grpah API.

经过API浏览器测试, https://graph.microsoft.io/en-us/graph-explorer#

Tested with API browser, https://graph.microsoft.io/en-us/graph-explorer#

按照以下要求运行,获得文件/文件夹项目信息的列表,

Ran following request, got list of file/folder item information,

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

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

And for one of the file item, I was able to get item information.

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

但是以下返回HTTP 404.

But following returns HTTP 404.

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

此症状的原因是什么?

推荐答案

不支持通过通过Grath Explorer发送到https://graph.microsoft.com/beta/me/drive/items/<itemid>/content端点的请求以 CORS行为.

The request sent to https://graph.microsoft.com/beta/me/drive/items/<itemid>/content endpoint via Grath Explorer is issued as a preflight request. The server responds with 302-Redirect but redirects are not allowed for preflighted requests due to CORS behavior.

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

Here is a workaround on how to download a file

以下驱动器项资源请求:

https://graph.microsoft.com/beta/me/drive/items/<itemId>

返回@microsoft.graph.downloadUrl批注,其中包含到文件资源的实际链接.

returns @microsoft.graph.downloadUrl annotation which contains the actual link to file resource.

一旦检索到驱动器项目资源,请执行另一个GET请求以从@microsoft.graph.downloadUrl进行url返回实际文件.

Once the drive item resource is retrieved, perform another GET request to url from @microsoft.graph.downloadUrl to return the actual file.

这篇关于Microsoft Graph下载文件内容返回404的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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