cli-microsoft365 icon indicating copy to clipboard operation
cli-microsoft365 copied to clipboard

Improve folder creation for SharePoint lists

Open Jwaegebaert opened this issue 6 months ago • 5 comments

When creating a folder in a SharePoint list using the REST API (and through the spo folder add command), the operation reports success, but the folder never shows up in the list view.

Digging deeper, you’ll see the folder is technically created when inspecting the rootFolder via REST, but it lacks any metadata, making it an internal-only folder that's invisible in the UI and unusable.

After quite a bit of searching, I found that using a different endpoint actually creates the folder properly with the required metadata:

/_api/web/GetFolderByServerRelativePath(DecodedUrl='/sites/examplesite/Shared Documents')/AddSubFolderUsingPath(DecodedUrl='NewFolder')

This endpoint ensures the folder is correctly surfaced and behaves as expected. I think we should update the spo folder add command to use this endpoint when targeting folders in lists. It may also be worth checking if other folder-related commands are affected by similar issues.

Has anyone else run into this before?

Jwaegebaert avatar Jul 18 '25 21:07 Jwaegebaert

Do you have any idea if this new endpoint works for libraries?

milanholemans avatar Jul 18 '25 22:07 milanholemans

Yes, this works for libraries as well

Jwaegebaert avatar Jul 23 '25 12:07 Jwaegebaert

@Jwaegebaert , @milanholemans sorry for the late update in this issue. I didn't have the opportunity to recheck that but if indeed does not work I thing it would be best to consider this a bug and fix it ASAP right?

Adam-it avatar Oct 19 '25 12:10 Adam-it

If it works for both lists and libraries, I don't see a reason why we shouldn't implement this API.

milanholemans avatar Oct 19 '25 16:10 milanholemans

Same here. If the previous APi stopped to work properly and we have this as alternative I would consider this a bug and open it up 👍. @Jwaegebaert ?

Adam-it avatar Oct 19 '25 16:10 Adam-it