APIs under the /beta version in Microsoft Graph are subject to change. Use of these APIs in production applications is not supported. To determine whether an API is available in v1.0, use the Version selector.
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.
In the request body, supply a JSON representation of the bundle to be created.
Response
If the request is successful, the driveItem representing the newly created bundle is returned.
Read the Error Responses topic for more info about how errors are returned.
Examples
Example 1: Create a bundle
The following example shows how to create a basic new bundle.
This request creates a new bundle named Just some files and adds 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.
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models;
var requestBody = new DriveItem
{
Name = "Just some files",
Bundle = new Bundle
{
},
Children = new List<DriveItem>
{
new DriveItem
{
Id = "1234asdf",
},
new DriveItem
{
Id = "1234qwerty",
},
},
AdditionalData = new Dictionary<string, object>
{
{
"@microsoft.graph.conflictBehavior" , "rename"
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Drives["{drive-id}"].Bundles.PostAsync(requestBody);
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewDriveItem()
name := "Just some files"
requestBody.SetName(&name)
bundle := graphmodels.NewBundle()
requestBody.SetBundle(bundle)
driveItem := graphmodels.NewDriveItem()
id := "1234asdf"
driveItem.SetId(&id)
driveItem1 := graphmodels.NewDriveItem()
id := "1234qwerty"
driveItem1.SetId(&id)
children := []graphmodels.DriveItemable {
driveItem,
driveItem1,
}
requestBody.SetChildren(children)
additionalData := map[string]interface{}{
"@microsoft.graph.conflictBehavior" : "rename",
}
requestBody.SetAdditionalData(additionalData)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
bundles, err := graphClient.Drives().ByDriveId("drive-id").Bundles().Post(context.Background(), requestBody, nil)
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
DriveItem driveItem = new DriveItem();
driveItem.setName("Just some files");
Bundle bundle = new Bundle();
driveItem.setBundle(bundle);
LinkedList<DriveItem> children = new LinkedList<DriveItem>();
DriveItem driveItem1 = new DriveItem();
driveItem1.setId("1234asdf");
children.add(driveItem1);
DriveItem driveItem2 = new DriveItem();
driveItem2.setId("1234qwerty");
children.add(driveItem2);
driveItem.setChildren(children);
HashMap<String, Object> additionalData = new HashMap<String, Object>();
additionalData.put("@microsoft.graph.conflictBehavior", "rename");
driveItem.setAdditionalData(additionalData);
DriveItem result = graphClient.drives().byDriveId("{drive-id}").bundles().post(driveItem);
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Models\DriveItem;
use Microsoft\Graph\Beta\Generated\Models\Bundle;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new DriveItem();
$requestBody->setName('Just some files');
$bundle = new Bundle();
$requestBody->setBundle($bundle);
$childrenDriveItem1 = new DriveItem();
$childrenDriveItem1->setId('1234asdf');
$childrenArray []= $childrenDriveItem1;
$childrenDriveItem2 = new DriveItem();
$childrenDriveItem2->setId('1234qwerty');
$childrenArray []= $childrenDriveItem2;
$requestBody->setChildren($childrenArray);
$additionalData = [
'@microsoft.graph.conflictBehavior' => 'rename',
];
$requestBody->setAdditionalData($additionalData);
$result = $graphServiceClient->drives()->byDriveId('drive-id')->bundles()->post($requestBody)->wait();
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
Import-Module Microsoft.Graph.Beta.Files
$params = @{
name = "Just some files"
"@microsoft.graph.conflictBehavior" = "rename"
bundle = @{
}
children = @(
@{
id = "1234asdf"
}
@{
id = "1234qwerty"
}
)
}
New-MgBetaDriveBundle -DriveId $driveId -BodyParameter $params
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.models.drive_item import DriveItem
from msgraph_beta.generated.models.bundle import Bundle
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = DriveItem(
name = "Just some files",
bundle = Bundle(
),
children = [
DriveItem(
id = "1234asdf",
),
DriveItem(
id = "1234qwerty",
),
],
additional_data = {
"@microsoft_graph_conflict_behavior" : "rename",
}
)
result = await graph_client.drives.by_drive_id('drive-id').bundles.post(request_body)
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
POST https://graph.microsoft.com/beta/drive/bundles
Content-Type: application/json
{
"name": "My Day at the Beach",
"@microsoft.graph.conflictBehavior" : "rename",
"bundle": { "album": {} },
"children": [
{ "id": "1234asdf" }
]
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models;
var requestBody = new DriveItem
{
Name = "My Day at the Beach",
Bundle = new Bundle
{
Album = new Album
{
},
},
Children = new List<DriveItem>
{
new DriveItem
{
Id = "1234asdf",
},
},
AdditionalData = new Dictionary<string, object>
{
{
"@microsoft.graph.conflictBehavior" , "rename"
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Drives["{drive-id}"].Bundles.PostAsync(requestBody);
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
mgc-beta drives bundles create --drive-id {drive-id} --body '{\
"name": "My Day at the Beach",\
"@microsoft.graph.conflictBehavior" : "rename",\
"bundle": { "album": {} },\
"children": [\
{ "id": "1234asdf" }\
]\
}\
'
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewDriveItem()
name := "My Day at the Beach"
requestBody.SetName(&name)
bundle := graphmodels.NewBundle()
album := graphmodels.NewAlbum()
bundle.SetAlbum(album)
requestBody.SetBundle(bundle)
driveItem := graphmodels.NewDriveItem()
id := "1234asdf"
driveItem.SetId(&id)
children := []graphmodels.DriveItemable {
driveItem,
}
requestBody.SetChildren(children)
additionalData := map[string]interface{}{
"@microsoft.graph.conflictBehavior" : "rename",
}
requestBody.SetAdditionalData(additionalData)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
bundles, err := graphClient.Drives().ByDriveId("drive-id").Bundles().Post(context.Background(), requestBody, nil)
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
DriveItem driveItem = new DriveItem();
driveItem.setName("My Day at the Beach");
Bundle bundle = new Bundle();
Album album = new Album();
bundle.setAlbum(album);
driveItem.setBundle(bundle);
LinkedList<DriveItem> children = new LinkedList<DriveItem>();
DriveItem driveItem1 = new DriveItem();
driveItem1.setId("1234asdf");
children.add(driveItem1);
driveItem.setChildren(children);
HashMap<String, Object> additionalData = new HashMap<String, Object>();
additionalData.put("@microsoft.graph.conflictBehavior", "rename");
driveItem.setAdditionalData(additionalData);
DriveItem result = graphClient.drives().byDriveId("{drive-id}").bundles().post(driveItem);
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Models\DriveItem;
use Microsoft\Graph\Beta\Generated\Models\Bundle;
use Microsoft\Graph\Beta\Generated\Models\Album;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new DriveItem();
$requestBody->setName('My Day at the Beach');
$bundle = new Bundle();
$bundleAlbum = new Album();
$bundle->setAlbum($bundleAlbum);
$requestBody->setBundle($bundle);
$childrenDriveItem1 = new DriveItem();
$childrenDriveItem1->setId('1234asdf');
$childrenArray []= $childrenDriveItem1;
$requestBody->setChildren($childrenArray);
$additionalData = [
'@microsoft.graph.conflictBehavior' => 'rename',
];
$requestBody->setAdditionalData($additionalData);
$result = $graphServiceClient->drives()->byDriveId('drive-id')->bundles()->post($requestBody)->wait();
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
Import-Module Microsoft.Graph.Beta.Files
$params = @{
name = "My Day at the Beach"
"@microsoft.graph.conflictBehavior" = "rename"
bundle = @{
album = @{
}
}
children = @(
@{
id = "1234asdf"
}
)
}
New-MgBetaDriveBundle -DriveId $driveId -BodyParameter $params
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.models.drive_item import DriveItem
from msgraph_beta.generated.models.bundle import Bundle
from msgraph_beta.generated.models.album import Album
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = DriveItem(
name = "My Day at the Beach",
bundle = Bundle(
album = Album(
),
),
children = [
DriveItem(
id = "1234asdf",
),
],
additional_data = {
"@microsoft_graph_conflict_behavior" : "rename",
}
)
result = await graph_client.drives.by_drive_id('drive-id').bundles.post(request_body)
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
If @microsoft.graph.conflictBehavior is set to rename and a bundle with the same name already exists, the new bundle name is updated to be unique.
OneDrive appends 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.