You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过Graph API下载SharePoint特定版本的文件?

Download a Specific Version of a File with Microsoft Graph API

Great question! You're already on the right track by fetching the version metadata—grabbing the actual file content for that specific version just requires a small tweak to your Graph API calls. Here's how to do it:

Method 1: Directly Call the Version Content Endpoint

The simplest way is to target the content sub-resource of the file version. Send a GET request to this endpoint, and it will return the binary content of the specified version directly:

GET /beta/sites/{site-id}/items/{item-id}/versions/{version-id}/content

You can handle the response as a download stream or save it directly to a file. For example, using curl:

curl -X GET "https://graph.microsoft.com/beta/sites/{site-id}/items/{item-id}/versions/{version-id}/content" \
  -H "Authorization: Bearer {your-access-token}" \
  --output "document-v2.pdf"

Method 2: Fetch the Download URL from Version Metadata

If you want to get the download link alongside the version metadata you're already retrieving, modify your existing request to expand the content resource instead of just fields:

GET /beta/sites/{site-id}/items/{item-id}/versions/{version-id}?expand=fields,content

In the response, you'll find a @microsoft.graph.downloadUrl property under the content section. This is a temporary, pre-authenticated URL you can use to download the file directly (no need to attach an authorization header for this URL).

Key Notes

  • Permissions: Ensure your app has the correct permissions—Files.Read (for read-only access) or Files.ReadWrite (if you need to modify/save the version) are the minimum required. For site-wide access, Sites.Read.All or similar may apply.
  • Beta Stability: While this endpoint is in the beta API, it's widely used and reliable for versioned file operations.
  • Large Files: For files larger than 4MB, consider using the resumable download pattern supported by Graph API, which involves using the download URL with range headers to fetch chunks of the file.

内容的提问来源于stack exchange,提问作者Sameer

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 03:47:30