msgraph-sdk-powershell icon indicating copy to clipboard operation
msgraph-sdk-powershell copied to clipboard

Update-MgSitePage doesn't cast a page as microsoft.graph.sitePage

Open joshtransient opened this issue 1 year ago • 0 comments

Describe the bug

When I run Update-MgSitePage -BodyParameter @{ canvasLayout = @{ ... } to change the content in canvasLayout, the command tries to PATCH "/v1.0/sites/{site-id}/pages/{page-id}", which doesn't work.

Per the doc page, the command is supposed to PATCH "/v1.0/sites/{site-id}/pages/{page-id}/microsoft.graph.sitePage"

Expected behavior

This command should not return an HTTP 400 when providing the ID of a site page.

How to reproduce

$site = Get-MgSite -SiteId ...
$pages = Get-MgSitePage -SiteId $siteId -Filter ...
foreach($page in $pages) {
  Update-MgSitePage -SiteId $siteId -BaseSitePageId $page.Id -BodyParameter @{ canvasLayout = @{ ... }
}

SDK Version

No response

Latest version known to work for scenario above?

2.22.0

Known Workarounds

As a workaround, I simply add '/microsoft.graph.sitePage' to the value I plug into {page-id}, and that seems to resolve the issue.

Debug output

Click to expand log ``` API not found

Status: 400 (BadRequest) ErrorCode: invalidRequest Date: 2024-08-22T14:50:41

Headers: Cache-Control : no-store, no-cache Vary : Accept-Encoding Strict-Transport-Security : max-age=31536000 (add'l headers removed for privacy)

</details>

### Configuration

- Windows 11 23H2 build 22631.4037
- x64 architecture
- PowerShell 7.4.5

### Other information

I assume the problem here is that the MgSitePage cmdlets aren't aware of the microsoft.graph.sitePage type, hence the lack of a `-SitePageId` argument instead of `-BaseSitePageId`.

joshtransient avatar Aug 22 '24 14:08 joshtransient