// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new DriveItem
{
ParentReference = new ItemReference
{
Id = "{new-parent-folder-id}",
},
Name = "new-item-name.txt",
};
// 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}"].Items["{driveItem-id}"].PatchAsync(requestBody);
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
DriveItem driveItem = new DriveItem();
ItemReference parentReference = new ItemReference();
parentReference.setId("{new-parent-folder-id}");
driveItem.setParentReference(parentReference);
driveItem.setName("new-item-name.txt");
DriveItem result = graphClient.drives().byDriveId("{drive-id}").items().byDriveItemId("{driveItem-id}").patch(driveItem);
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Models\DriveItem;
use Microsoft\Graph\Generated\Models\ItemReference;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new DriveItem();
$parentReference = new ItemReference();
$parentReference->setId('{new-parent-folder-id}');
$requestBody->setParentReference($parentReference);
$requestBody->setName('new-item-name.txt');
$result = $graphServiceClient->drives()->byDriveId('drive-id')->items()->byDriveItemId('driveItem-id')->patch($requestBody)->wait();