How to create Document Library in Sharepont subsite using Graph API ?

Dnyaneshwar Surywanshi 41 Reputation points
2020-09-24T11:55:33.357+00:00

I want to create Document Library in my subsite using graph API.28028-documentlibrary.png

In Attached screenshot i have created two Document Library manually so I want to create same using graph API.

Microsoft 365 and Office | SharePoint Server | For business
Microsoft 365 and Office | SharePoint | For business | Windows
Microsoft 365 and Office | SharePoint Server | Development
0 comments No comments
{count} votes

Answer accepted by question author
  1. sadomovalex 3,636 Reputation points
    2020-09-24T14:16:15.617+00:00

    hi, try bellow code:

    GraphServiceClient graphClient = new GraphServiceClient( authProvider );
    
    var list = new List
    {
        DisplayName = "Books",
        Columns = (IListColumnsCollectionPage)new List<ColumnDefinition>()
        {
            new ColumnDefinition
            {
                Name = "Author",
                Text = new TextColumn
                {
                }
            },
            new ColumnDefinition
            {
                Name = "PageCount",
                Number = new NumberColumn
                {
                }
            }
        },
        ListInfo = new ListInfo
        {
            Template = "genericList"
        }
    };
    
    await graphClient.Sites["{site-id}"].Lists
        .Request()
        .AddAsync(list);
    
    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.