I'm working on a C# project with these requirements:
From Onedrive API documentation Create a new Folder in OneDrive, it says that setting @microsoft.graph.conflictBehavior=rename would increment the folder value if it exists
how can I add the @microsoft.graph.conflictBehavior into my request?
Here's the code which creates the folder using drive Item
var foldertoCreate = new DriveItem {
Name = $"TestFolder",
Folder = new Folder (),
};
var newFolder = await _graphClient.Drive
.Items["MyParent_Item_Id"]
.Children
.Request ()
.AddAsync (foldertoCreate);
I believe you should be able to add the annotation manually via AdditionalData
. Obviously this isn't ideal, but I cannot see another way to do it with the current SDK.
var foldertoCreate = new DriveItem
{
Name = $"TestFolder",
Folder = new Folder(),
AdditionalData = new Dictionary<string, object>
{
{ "@microsoft.graph.conflictBehavior", "rename" }
},
};
var newFolder = await _graphClient.Drive
.Items["MyParent_Item_Id"]
.Children
.Request()
.AddAsync(foldertoCreate);