Microsoft Graph download file content returns 404

。_饼干妹妹 提交于 2019-12-11 06:58:13

问题


I tried to download a file with Grpah API.

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

But following returns HTTP 404.

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

What will be the cause for this symptom?


回答1:


It is not supported to perform request to https://graph.microsoft.com/beta/me/drive/items/<itemid>/content endpoint via Graph Explorer.

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

The following drive item resource request:

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

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

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



来源:https://stackoverflow.com/questions/40388152/microsoft-graph-download-file-content-returns-404

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!