How to add folder to SharePoint document library?
See original GitHub issueCategory
- Bug
Describe the bug
[2020-10-14T06:39:35.203] Error while processing change
[2020-10-14T06:39:35.204] PnP.Core: Unresolved tokens found in API call https://{tenant}.sharepoint.com/sites/{sitecollection}/_api/Web/getFolderById('{Parent.Id}')/Folders/Add('2020-10sdfs').
Steps to reproduce
public async Task<string> EnsureFolder(string folderName)
{
_logger.LogInformation($"Creating folder={folderName}");
using (var ctx = await _pnpContextFactory.CreateAsync(new Uri(_absSiteUrl)))
{
var list = await ctx.Web.Lists.GetByTitleAsync("Site Pages");
var folder = await list.RootFolder.AddFolderAsync(folderName + "sdfs");
return folder.ServerRelativeUrl;
}
}
Expected behavior
The new folder should be created.
Environment details (development & target environment)
- SDK version: 0.3.11.0
- OS: Windows
- SDK used in: Azure Function
- Framework: .NET Core v3.x
- Tooling: Visual Studio 2019
- Additional details:
Thanks for your contribution! Sharing is caring.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
How to Create a Folder in SharePoint
In the document library where you want to create a folder, click on the + New dropdown button and select Folder from the...
Read more >SharePoint: How to Add a Folder
Launch the SharePoint site where you wish to add the new folder, then open the “Document Library.” · From the menu, select “+...
Read more >How to Create Folders in SharePoint: A Visual Guide
On the menu bar, select + New, and then select Folder. After naming and creating the folder, click on the ellipsis (…) next...
Read more >Solved: How to Create a Folder in SharePoint in 2023
Step 2: Head to the Communication Site and go to the document library. Then, press the New button to select Folder on the...
Read more >SharePoint: How to Add a New Folder to a Document Library
In the Ribbon, click the Files tab, and then click New Folder. In the New Folder dialog box, type a folder name in...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This one works for me:
Hello @piteerus,
Thanks for reporting this, I think we may probably address that issue making sure the RootFolder is properly loaded and initialized in the AddFolderAsync method. We’ll need to think about the best way to handle it ( cc @jansenbe ).
[EDIT] After double-checking with Bert, it indeed looks like this one I mentioned is neither working… We will think about it and most likely address that issue.
The following snippet is from our passing unit test
It’s a bit less fluent style…, but this one works
Again, thanks for trying out the PnP Core SDK !
Regards, Yannick