0

I am trying to add a folder to a drive in a SharePoint site. I have tried many examples yet I am always receiving a 500 Internal Server Error. I have allocated and consented to the permissions as stated are required by the ms docs for adding files to a drive: Files.ReadWrite.All, Sites.ReadWrite.All

 var folder = new DriveItem
        {
            Name = "New Folder",
            Folder = new Folder(),
            AdditionalData = new Dictionary<string, object>()
            {
                {"@microsoft.graph.conflictBehavior","fail"}
            },
        };

And here are just two examples of the queries I have tried executing:

await graphClient.Groups[groupId]
                 .Sites[siteId]
                 .Lists[listId]
                 .Drive
                 .Root
                 .ItemWithPath("/{Custom Parent Folder I want to add a folder to}")
                 .Children
                 .Request()
                 .AddAsync(folder);

await graphClient.Sites[siteId]
             .Drives[driveId]
             .Root
             .Children
             .Request()
             .AddAsync(folder);

await graphClient.Sites[siteId]
                 .Lists[listId]
                 .Drive
                 .Root
                 .Children
                 .Request()
                 .AddAsync(folder);

Whether trying to add the folder to a custom document library or the root 'Documents' still results in an invalid request. This is my first time using Graph and the SDK so I am likely missing something.

Thank you for any help.

Joao Ricardo
  • 311
  • 3
  • 6

1 Answers1

0

Frustratingly, I created a new app registration in azure and it worked.

Joao Ricardo
  • 311
  • 3
  • 6