Based on this documentation, i was able te move a file from a folder to another like so:
DriveItem file = await graphClient
.Me
.Drive
.Items[fileId]
.Request()
.UpdateAsync(new DriveItem
{
Name = "New Name",
ParentReference = new ItemReference
{
Path = "/drive/root:/New/Path"
},
AdditionalData = new Dictionary<string, object>
{
{ "@microsoft.graph.conflictBehavior", "rename" }
}
});
If I use the same logic to move a whole folder from its parent folder to another, I get this error: \
InvalidRequest: Must provide one of the following facets to create an item: Bundle, File, Folder, RemoteItem
If I add Folder = new Folder{ }
in the DriveItem attributes, I get this error:
InvalidRequest: Bad Argument
I was actually using the path of the folder and not its id.
DriveItem file = await graphClient
.Me
.Drive
.Root
.ItemWithPath(path)
.Request()
//...
That seemed to be, for an unclear reason, why the request failed. If I use the id (.Items[fileId]
), it works.