Reputation: 463
I'm trying to create a folder withing my Apps/[appName] folder.
Here is the code:
var request = OneDriveService.Drive.Special.AppRoot.Request().CreateAsync(new Item()
{
Name = name,
});
request.Wait();
But I keep getting the error message:
{Code: invalidRequest Throw site: 1c0e.2859 Message: The name in the provided oneDrive.item does not match the name in the URL }
Does anyone know what it means?
Upvotes: 3
Views: 588
Reputation: 1054
Instead of CreateAsync I write this code:
try
{
var documentsBuilder = this.oneDriveClient.Drive.Root.ItemWithPath("Documents");
var children = await documentsBuilder.Children.Request().GetAsync();
// try to find existing folder
var folder = children.FirstOrDefault(c => c.Name.Equals("Some folder"));
// create it if it doesn't exist
if (folder == null)
{
var newFolder = new Item { Name = "Some folder", Folder = new Folder() };
await documentsBuilder.Children.Request().AddAsync(newFolder);
}
}
catch (OneDriveException exception)
{
throw;
}
Upvotes: 1