pnp / pnp/cli-microsoft365

Improve folder creation for SharePoint lists

Open
#6,804 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

needs research
Dominant language
TypeScript
Stars
1.5k
Forks
413
Avg merge
5d 6h
Merged PRs (30d)
21

Description

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?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the spo folder add command and compare its current folder-creation request with the SharePoint AddSubFolderUsingPath endpoint shown in the issue. Verify the resulting folder appears in the list view with metadata, and check whether related folder commands show the same behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.