Skip to content

Commit 6d13aae

Browse files
authored
Merge pull request #27703 from microsoftgraph/users/dluces/driveItemVersion_range_support
Document support for Range header for driveItemVersion get content
2 parents 573b6ea + bb77498 commit 6d13aae

3 files changed

Lines changed: 60 additions & 12 deletions

File tree

api-reference/beta/api/driveitemversion-get-contents.md

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
author: spgraph-docs-team
33
description: "Retrieve the contents of a specific version of a driveItem."
4-
ms.date: 09/10/2017
4+
ms.date: 12/11/2025
55
title: Download a previous version
66
ms.localizationpriority: medium
77
ms.subservice: "sharepoint"
@@ -49,12 +49,13 @@ Many HTTP client libraries will automatically follow the 302 redirection and sta
4949

5050
Preauthenticated download URLs are only valid for a short period of time (a few minutes) and don't require an `Authorization` header to download.
5151

52-
## Example
52+
## Examples
5353

54-
This example retrieves a version of a file in the current user's drive.
54+
### Example 1: Download the contents of a previous version of a file
5555

56-
### Request
56+
This example retrieves a version of a file in the current user's drive.
5757

58+
#### Request
5859

5960
# [HTTP](#tab/http)
6061
<!-- { "blockType": "request", "name": "get-version-contents", "scopes": "files.read", "tags": "service.graph" } -->
@@ -93,7 +94,7 @@ GET /me/drive/items/{item-id}/versions/{version-id}/content
9394

9495
---
9596

96-
### Response
97+
#### Response
9798

9899
Returns a redirect to where the contents of the version can be downloaded.
99100

@@ -104,6 +105,28 @@ HTTP/1.1 302 Redirect
104105
Location: https://onedrive.com/34FF49D6...
105106
```
106107

108+
### Example 2: Download a partial range of bytes from a previous version of a file
109+
110+
To download a partial range of bytes from a **driveItemVersion**, your app can use the `Range` header as specified in [RFC 2616](https://www.ietf.org/rfc/rfc2616.txt). You must append the `Range` header when following the redirect and not to the request for `/content`.
111+
112+
<!-- { "blockType": "request", "opaqueUrl": true, "name": "download-version-partial", "scopes": "files.read" } -->
113+
114+
```http
115+
GET https://onedrive.com/34FF49D6...
116+
Range: bytes=0-1023
117+
```
118+
119+
The call returns an `HTTP 206 Partial Content` response with the request range of bytes from the file.
120+
If the range can't be generated, then the `Range` header may be ignored and an `HTTP 200` response would be returned with the full contents of the file.
121+
122+
<!-- { "blockType": "response", "name": "download-version-partial", "@odata.type": "stream" } -->
123+
124+
```http
125+
HTTP/1.1 206 Partial Content
126+
Content-Range: bytes 0-1023/2048
127+
128+
<first 1024 bytes of file>
129+
```
107130

108131
## Remarks
109132

api-reference/v1.0/api/driveitemversion-get-contents.md

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ ms.localizationpriority: medium
55
ms.subservice: "sharepoint"
66
author: "spgraph-docs-team"
77
doc_type: apiPageType
8-
ms.date: 03/06/2024
8+
ms.date: 12/11/2025
99
---
1010

1111
# Download contents of a driveItemVersion resource
@@ -55,12 +55,13 @@ Many HTTP client libraries will automatically follow the 302 redirection and sta
5555

5656
Preauthenticated download URLs are only valid for a short period of time (a few minutes) and don't require an `Authorization` header to download.
5757

58-
## Example
58+
## Examples
5959

60-
This example retrieves a version of a file in the current user's drive.
60+
### Example 1: Download the contents of a previous version of a file
6161

62-
### Request
62+
This example retrieves a version of a file in the current user's drive.
6363

64+
#### Request
6465

6566
# [HTTP](#tab/http)
6667
<!-- { "blockType": "request", "name": "get-version-contents", "scopes": "files.read", "tags": "service.graph" } -->
@@ -99,7 +100,7 @@ GET /me/drive/items/{item-id}/versions/{version-id}/content
99100

100101
---
101102

102-
### Response
103+
#### Response
103104

104105
The call returns a redirect to where the contents of the version can be downloaded.
105106

@@ -110,6 +111,28 @@ HTTP/1.1 302 Found
110111
Location: https://onedrive.com/34FF49D6...
111112
```
112113

114+
### Example 2: Download a partial range of bytes from a previous version of a file
115+
116+
To download a partial range of bytes from a **driveItemVersion**, your app can use the `Range` header as specified in [RFC 2616](https://www.ietf.org/rfc/rfc2616.txt). You must append the `Range` header when following the redirect and not to the request for `/content`.
117+
118+
<!-- { "blockType": "request", "opaqueUrl": true, "name": "download-version-partial", "scopes": "files.read" } -->
119+
120+
```http
121+
GET https://onedrive.com/34FF49D6...
122+
Range: bytes=0-1023
123+
```
124+
125+
The call returns an `HTTP 206 Partial Content` response with the request range of bytes from the file.
126+
If the range can't be generated, then the `Range` header may be ignored and an `HTTP 200` response would be returned with the full contents of the file.
127+
128+
<!-- { "blockType": "response", "name": "download-version-partial", "@odata.type": "stream" } -->
129+
130+
```http
131+
HTTP/1.1 206 Partial Content
132+
Content-Range: bytes 0-1023/2048
133+
134+
<first 1024 bytes of file>
135+
```
113136

114137
## Remarks
115138

concepts/whats-new-overview.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,11 @@ Using the **signInAudience** property to limit where an [application](/graph/api
2626

2727
### Files
2828

29-
Use the following new container columns APIs added to further support structured file storage in SharePoint Embedded applications:
29+
- Use the following new container columns APIs added to further support structured file storage in SharePoint Embedded applications:
3030
- [Get column](/graph/api/filestoragecontainer-get-column)
3131
- [Update column](/graph/api/filestoragecontainer-update-column)
3232
- [Delete column](/graph/api/filestoragecontainer-delete-column)
33+
- [Download a partial range of bytes from a previous version of a file](/graph/api/driveitemversion-get-contents#example-2-download-a-partial-range-of-bytes-from-a-previous-version-of-a-file).
3334

3435
### Identity and access | Directory management
3536

@@ -86,7 +87,8 @@ Use the [follow user](/graph/api/storyline-follow?view=graph-rest-beta&preserve-
8687

8788
### Files
8889

89-
Added support for the `DELETE /groups/{group-id}/drive/items/{item-id}/retentionLabel`, `DELETE /me/drive/items/{item-id}/retentionLabel`, and `DELETE /users/{user-id}/drive/items/{item-id}/retentionLabel` endpoints to the [driveItem: removeRetentionLabel](/graph/api/driveitem-removeretentionlabel?view=graph-rest-beta&preserve-view=true) API.
90+
- Added support for the `DELETE /groups/{group-id}/drive/items/{item-id}/retentionLabel`, `DELETE /me/drive/items/{item-id}/retentionLabel`, and `DELETE /users/{user-id}/drive/items/{item-id}/retentionLabel` endpoints to the [driveItem: removeRetentionLabel](/graph/api/driveitem-removeretentionlabel?view=graph-rest-beta&preserve-view=true) API.
91+
- [Download a partial range of bytes from a previous version of a file](/graph/api/driveitemversion-get-contents#example-2-download-a-partial-range-of-bytes-from-a-previous-version-of-a-file).
9092

9193
### Files | File storage container
9294

0 commit comments

Comments
 (0)