Frage

I want create new folder in library.
If I would like to create a folder in Shared Documents I can run this code:

public async Task<string> CreateFolder(string title)
{
    var driveItem = new DriveItem
    {
        Name = title,
        Folder = new Folder
        {

        },
        AdditionalData = new Dictionary<string, object>()
        {
            {"@microsoft.graph.conflictBehavior","rename"}
        }
    };

    return await CreateGraphClient().Groups[groupId].Sites[siteId].Drive.Root.Children.Request().AddAsync(driveItem).ConfigureAwait(false);
}

How should I modified that code to create a new folder in other library than Shared Documents which is on the same site?

War es hilfreich?

Lösung

Okey, I got it:

await CreateGraphClient().Groups[groupId].Sites[siteId]
                        .Lists[listId]
                        .Drive
                        .Root
                        .Children
                        .Request()
                        .AddAsync(driveItem)

Where Lists[listId] is your custom library id, base on this post: https://stackoverflow.com/questions/56266087/microsoft-graph-api-client-library-create-a-folder

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit sharepoint.stackexchange
scroll top