| author | spgraph-docs-team |
|---|---|
| title | Create bundle |
| description | Create a bundle of driveItems |
| ms.localizationpriority | medium |
| ms.subservice | sharepoint |
| doc_type | apiPageType |
| ms.date | 04/04/2024 |
Namespace: microsoft.graph
Add a new bundle to the user's drive.
[!INCLUDE national-cloud-support]
Choose the permission or permissions marked as least privileged for this API. Use a higher privileged permission or permissions only if your app requires it. For details about delegated and application permissions, see Permission types. To learn more about these permissions, see the permissions reference.
[!INCLUDE permissions-table]
POST /drive/bundles| Name | Description |
|---|---|
| Authorization | Bearer {token}. Required. Learn more about authentication and authorization. |
In the request body, supply a JSON representation of the bundle to be created.
If the request is successful, the driveItem representing the newly created bundle will be returned.
For information about error responses, see Error responses.
The following example shows how to create a basic new bundle.
This request will create a new bundle named Just some files and add two existing items to the bundle.
This bundle can be used to share a collection of files with other users without sharing the folder those items are stored in.
POST https://graph.microsoft.com/v1.0/drive/bundles
Content-Type: application/json
{
"name": "Just some files",
"@microsoft.graph.conflictBehavior" : "rename",
"bundle": { },
"children": [
{ "id": "1234asdf" },
{ "id": "1234qwerty" }
]
}[!INCLUDE sample-code] [!INCLUDE sdk-documentation]
[!INCLUDE sample-code] [!INCLUDE sdk-documentation]
[!INCLUDE sample-code] [!INCLUDE sdk-documentation]
[!INCLUDE sample-code] [!INCLUDE sdk-documentation]
[!INCLUDE sample-code] [!INCLUDE sdk-documentation]
[!INCLUDE sample-code] [!INCLUDE sdk-documentation]
[!INCLUDE sample-code] [!INCLUDE sdk-documentation]
HTTP/1.1 201 Created
Content-Type: application/json
{
"id": "1234321!abc",
"name": "Just some files",
"bundle": {
"childCount": 2
}
}The response object shown here might be shortened for readability.
The request to create a new photo album is similar, although inside the bundle facet, the album property is set to a non-null value.
POST https://graph.microsoft.com/v1.0/drive/bundles
Content-Type: application/json
{
"name": "My Day at the Beach",
"@microsoft.graph.conflictBehavior" : "rename",
"bundle": { "album": {} },
"children": [
{ "id": "1234asdf" }
]
}[!INCLUDE sample-code] [!INCLUDE sdk-documentation]
[!INCLUDE sample-code] [!INCLUDE sdk-documentation]
[!INCLUDE sample-code] [!INCLUDE sdk-documentation]
[!INCLUDE sample-code] [!INCLUDE sdk-documentation]
[!INCLUDE sample-code] [!INCLUDE sdk-documentation]
[!INCLUDE sample-code] [!INCLUDE sdk-documentation]
[!INCLUDE sample-code] [!INCLUDE sdk-documentation]
HTTP/1.1 201 Created
Content-Type: application/json
{
"id": "1234321!abc",
"name": "Just some files",
"bundle": {
"childCount": 2,
"album": { }
}
}The response object shown here might be shortened for readability.
If @microsoft.graph.conflictBehavior is set to rename and a bundle with the same name already exists, the new bundle name will be updated to be unique. OneDrive will append a number to the end of the bundle name.
For example, My Day at the Beach would be renamed My Day at the Beach 1.
If My Day at the Beach 1 is taken, then the number would be incremented again until a unique bundle name is discovered.