我在Web浏览器中使用以下方法使用Microsoft Graph获取DriveItem的文件内容:

GET /drives/{drive-id}/items/{item-id}
// Get the @microsoft.graph.downloadUrl property of the returned DriveItem
GET {downloadUrl}

这需要两个 GET 调用 .

我也知道这个API:

GET /drives/{drive-id}/items/{item-id}/content

如此处所述:

Download the contents of a DriveItem .

/content endpoints 有两个问题:

  • 它返回302 Found响应,导致重定向,需要另一个往返来获取内容

  • API在使用XHR的JavaScript应用程序中不起作用,如本文所述:OneDrive - CORS support

如何在一个请求中获取DriveItem的文件内容?