Priority
(Medium) I'm annoyed but I'll live
Description
Running spo page section add via the JS API when the file is not already checked out seems to check out the file but then fail to actually add the section. However the command still succeeds and throws no error. This is possibly the case with other page manipulation functions too, but I haven't been able to test any others.
Steps to reproduce
Here is a simple script that demonstrates my issue.
npm install @pnp/cli-microsoft365
- Replace the domain and site name in the below script and save it as
demo.js
- Run
node demo.js
#!/usr/bin/env node
const { executeCommand } = require('@pnp/cli-microsoft365');
async function demo(){
const page = "demo.aspx"
const listener = {
stdout: console.log,
stderr: console.error
}
const options = {
webUrl: "<MY SHAREPOINT DOMAIN>/sites/<MY SITE NAME>",
debug: true
}
console.error("Adding page")
await executeCommand("spo page add", {
name: page,
...options
}, listener)
console.error("Adding section")
await executeCommand("spo page section add", {
pageName: page,
...options
}, listener)
console.error("Listing sections")
await executeCommand("spo page section list", {
pageName: page,
...options
}, listener)
}
demo()
- Run
m365 spo page section list --webUrl <MY URL> --pageName demo.aspx
Expected results
I would expect the above commands to create a new section in the newly created page.
Actual results
The m365 spo page section list command returns nothing, indicating that no sections exist.
Also, if you inspect the (very verbose) debug output, and look at the API calls made after "Adding section" is called but before "Listing sections", we have:
/_api/sitepages/pages/GetByUrl('sitepages/demo.aspx')?$select=CanvasContent1,IsPageCheckedOutToCurrentUser
/_api/sitepages/pages/GetByUrl('sitepages/demo.aspx')/checkoutpage
In other words, the file is being checked out but not actually modified.
Interestingly, if you modify the above script and duplicate the section creation (run it twice), the first call checks out the file, and the second call does the actual creation. This acts as a workaround for now.
I love the auto-checkout functionality, it's very user friendly, but it would be nice for the command to do the thing being requested as well.
Diagnostics
No response
CLI for Microsoft 365 version
v6.7.0
nodejs version
v18.15.0
Operating system (environment)
Linux
Shell
zsh
cli doctor
{
"os": {
"platform": "darwin",
"version": "Darwin Kernel Version 21.6.0: Mon Aug 22 20:20:07 PDT 2022; root:xnu-8020.140.49~2/RELEASE_ARM64_T8110",
"release": "21.6.0"
},
"cliVersion": "6.7.0",
"nodeVersion": "v18.15.0",
"cliAadAppId": "31359c7f-bd7e-475c-86db-fdb8c937548e",
"cliAadAppTenant": "common",
"authMode": "DeviceCode",
"cliEnvironment": "",
"cliConfig": {},
"roles": [],
"scopes": [
"AllSites.FullControl",
"AppCatalog.ReadWrite.All",
"ChannelMember.ReadWrite.All",
"ChannelMessage.Send",
"ChannelSettings.ReadWrite.All",
"Directory.AccessAsUser.All",
"Directory.ReadWrite.All",
"Group.ReadWrite.All",
"IdentityProvider.ReadWrite.All",
"Mail.ReadWrite",
"Mail.Send",
"Policy.Read.All",
"Reports.Read.All",
"Tasks.ReadWrite",
"Team.Create",
"TeamMember.ReadWrite.All",
"TeamsApp.ReadWrite.All",
"TeamsAppInstallation.ReadWriteForUser",
"TeamSettings.ReadWrite.All",
"TeamsTab.ReadWrite.All",
"TermStore.ReadWrite.All",
"User.Invite.All",
"User.ReadWrite.All",
"profile",
"openid",
"email",
"AllSites.FullControl",
"AppCatalog.ReadWrite.All",
"ChannelMember.ReadWrite.All",
"ChannelMessage.Send",
"ChannelSettings.ReadWrite.All",
"Directory.AccessAsUser.All",
"Directory.ReadWrite.All",
"Group.ReadWrite.All",
"IdentityProvider.ReadWrite.All",
"Mail.ReadWrite",
"Mail.Send",
"Policy.Read.All",
"Reports.Read.All",
"Tasks.ReadWrite",
"Team.Create",
"TeamMember.ReadWrite.All",
"TeamsApp.ReadWrite.All",
"TeamsAppInstallation.ReadWriteForUser",
"TeamSettings.ReadWrite.All",
"TeamsTab.ReadWrite.All",
"TermStore.ReadWrite.All",
"User.Invite.All",
"User.ReadWrite.All",
"AllSites.FullControl",
"AppCatalog.ReadWrite.All",
"ChannelMember.ReadWrite.All",
"ChannelMessage.Send",
"ChannelSettings.ReadWrite.All",
"Directory.AccessAsUser.All",
"Directory.ReadWrite.All",
"Group.ReadWrite.All",
"IdentityProvider.ReadWrite.All",
"Mail.ReadWrite",
"Mail.Send",
"Policy.Read.All",
"Reports.Read.All",
"Tasks.ReadWrite",
"Team.Create",
"TeamMember.ReadWrite.All",
"TeamsApp.ReadWrite.All",
"TeamsAppInstallation.ReadWriteForUser",
"TeamSettings.ReadWrite.All",
"TeamsTab.ReadWrite.All",
"TermStore.ReadWrite.All",
"User.Invite.All",
"User.ReadWrite.All"
]
}
Additional Info
No response
Priority
(Medium) I'm annoyed but I'll live
Description
Running
spo page section addvia the JS API when the file is not already checked out seems to check out the file but then fail to actually add the section. However the command still succeeds and throws no error. This is possibly the case with other page manipulation functions too, but I haven't been able to test any others.Steps to reproduce
Here is a simple script that demonstrates my issue.
npm install @pnp/cli-microsoft365demo.jsnode demo.jsm365 spo page section list --webUrl <MY URL> --pageName demo.aspxExpected results
I would expect the above commands to create a new section in the newly created page.
Actual results
The
m365 spo page section listcommand returns nothing, indicating that no sections exist.Also, if you inspect the (very verbose) debug output, and look at the API calls made after "Adding section" is called but before "Listing sections", we have:
/_api/sitepages/pages/GetByUrl('sitepages/demo.aspx')?$select=CanvasContent1,IsPageCheckedOutToCurrentUser/_api/sitepages/pages/GetByUrl('sitepages/demo.aspx')/checkoutpageIn other words, the file is being checked out but not actually modified.
Interestingly, if you modify the above script and duplicate the section creation (run it twice), the first call checks out the file, and the second call does the actual creation. This acts as a workaround for now.
I love the auto-checkout functionality, it's very user friendly, but it would be nice for the command to do the thing being requested as well.
Diagnostics
No response
CLI for Microsoft 365 version
v6.7.0
nodejs version
v18.15.0
Operating system (environment)
Linux
Shell
zsh
cli doctor
Additional Info
No response