Can not create folder in SharePoint. (Upgrade MS Graph SDK 5.36.0 -> 5.44.0 version)

Jackie Dinh 0 Reputation points
2024-03-01T09:55:11.3+00:00

I try to use below code to create folder in SharePoint.

DriveItem driveItem;
var driveItemAdd = new DriveItem()

{

Name = folder.Name,

Folder = new Microsoft.Graph.Models.Folder()

{

    OdataType = "microsoft.graph.folder"

}
```};  
  
driveItem = await GraphFolderService.CreateDriveFolder(collection.SPSiteId.ToString(), collection.SPLibraryId.ToString(), driveItemAdd);  
  
 public async Task
SharePoint Server
SharePoint Server
A family of Microsoft on-premises document management and storage systems.
2,227 questions
SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
9,682 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. RaytheonXie_MSFT 31,606 Reputation points Microsoft Vendor
    2024-03-04T02:01:30.6033333+00:00

    Hi @Jackie Dinh,

    Per my research, you could use following code to create the folder in msgraph-sdk

    var folder = new DriveItem
    {
        Name = "<sub folder name>",
        Folder = new Folder()
    };
    
    var result = await graphClient
        .Sites[siteId]
        .Lists[listId]
        .Drive
        .Root
        .ItemWithPath("<folder path>")
        .Children
        .Request()
        .AddAsync(folder);
    
    
    

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.