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.
// Code snippets are only available for the latest version. Current version is 5.x
var graphClient = new GraphServiceClient(requestAdapter);
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"
},
},
};
var result = await graphClient.Drives["{drive-id}"].Bundles.PostAsync(requestBody);
<?php
// THIS SNIPPET IS A PREVIEW FOR THE KIOTA BASED SDK. NON-PRODUCTION USE ONLY
$graphServiceClient = new GraphServiceClient($requestAdapter);
$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);
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" }
]
}
// Code snippets are only available for the latest version. Current version is 5.x
var graphClient = new GraphServiceClient(requestAdapter);
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"
},
},
};
var result = await graphClient.Drives["{drive-id}"].Bundles.PostAsync(requestBody);
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
DriveItem driveItem = new DriveItem();
driveItem.name = "My Day at the Beach";
driveItem.additionalDataManager().put("@microsoft.graph.conflictBehavior", new JsonPrimitive("rename"));
Bundle bundle = new Bundle();
Album album = new Album();
bundle.album = album;
driveItem.bundle = bundle;
LinkedList<DriveItem> childrenList = new LinkedList<DriveItem>();
DriveItem children = new DriveItem();
children.id = "1234asdf";
childrenList.add(children);
DriveItemCollectionResponse driveItemCollectionResponse = new DriveItemCollectionResponse();
driveItemCollectionResponse.value = childrenList;
DriveItemCollectionPage driveItemCollectionPage = new DriveItemCollectionPage(driveItemCollectionResponse, null);
driveItem.children = driveItemCollectionPage;
graphClient.drive().bundles()
.buildRequest()
.post(driveItem);
<?php
// THIS SNIPPET IS A PREVIEW FOR THE KIOTA BASED SDK. NON-PRODUCTION USE ONLY
$graphServiceClient = new GraphServiceClient($requestAdapter);
$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);
Import-Module Microsoft.Graph.Files
$params = @{
name = "My Day at the Beach"
"@microsoft.graph.conflictBehavior" = "rename"
bundle = @{
album = @{
}
}
children = @(
@{
id = "1234asdf"
}
)
}
New-MgDriveBundle -DriveId $driveId -BodyParameter $params
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.