Skip to content

New flag: spo page set --content #4840

@multimeric

Description

@multimeric

Usage

spo page set --content

Description

Note: this is an existing command. I'm just proposing the addition of a new flag to it. The new command description could be:

Updates modern page properties and content

Options

Option Description
--content JSON content to be used to populate the list of controls in the SharePoint page

Examples

Update an entire page to a single text control that says "Hello world"

spo page set --name page.aspx --webUrl https://contoso.sharepoint.com/sites/a-team --content '[
  {
    "controlType": 4,
    "id": "42b8afe8-dafe-4c11-bfbf-df5ef5b1feb7",
    "position": {
      "layoutIndex": 1,
      "zoneIndex": 1,
      "sectionIndex": 1,
      "sectionFactor": 12,
      "controlIndex": 1
    },
    "addedFromPersistedData": true,
    "innerHTML": "<p>Hello World</p>"
  }]'

Additional Info

  • Firstly, it seems possible to do this already using the SharePoint API. When a user runs m365 spo page control set [...] --debug, it prints out the web request being made, and /_api/sitepages/pages/GetByUrl('sitepages/site.aspx')/SavePageAsDraft seems to accept a data field that sets all the properties of the page in one go.
  • The name of the field that I want to be updated by the --content flag is a key within the aforementioned data field, called canvasContent, which seems to be a JSON list of controls. Making this mutable would increase the power of the spo API considerably
  • You can view this field by running m365 spo page get and looking at the canvasContentJson field. This corresponds to the exact data that I want to manipulate
  • Adding this flag would unlock numerous new capabilities including:
    • Deleting and modifying sections
    • Deleting and modifying plain text controls, which currently cannot be modified using spo page control set
    • Re-arranging sections and controls

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions