Easy Way to Update a SharePoint Content Type

There was a time when I copied a page from one site to another. It was all good until I updated the page, and it will not let me save it. In this case, one possible reason is that the page content type changed from a Site Page to a Wiki Page. So, what can we do about this? Well, we can automatically update the site page’s content type to a Site Page using a Rest endpoint. A bit of tips for SharePoint content types can be found at SharePoint Content Type bits of tips!

Create a flow that will update the page’s content type to a Site Page. Use Send an HTTP Request to SharePoint action to use the Rest endpoint. First, add the Send an HTTP Request to SharePoint action.

Content Type

Site Address

Enter the Site Address. It should be the site where the page you want to update is sitting.


Method

For the Method, use the PATCH method. A Patch request lets you do a partial update to a resource. So we will use this method since we are updating a page property.


Headers

Since we are updating a file, we will use two headers for our action. These are the headers:

KeyValue
Content-typeapplication/json;odata=verbose
If-Match*


Body

For the body, you need to get the Id of the content type Site Page. It is better to get the Content Type Id dynamically so it will be easier when deploying the flow to another site or tenant. As for me, I checked the content type Id, and it is ‘0x0101009D1CB255DA76424F860D91F20E6C411800B6848D34B694474D993DD9F361193228’. 

{
              '__metadata': {'type': 'SP.Data.SitePagesItem'},
              'ContentTypeId': '0x0101009D1CB255DA76424F860D91F20E6C411800B6848D34B694474D993DD9F361193228'
}

For the metadata type, we will be using SP.Data.SitePagesItem because we are updating a file inside the Site Pages document library. Note that you can only update the page if it is checked out. After updating the page’s content type, I suggest publishing it to check out the page again.

That’s it! For questions and clarifications, please write it as a comment below. Have a nice day! 

Accounting.js Automation Collaboration Competitors Connect Content Type Design Expand Flows Hillbilly Tabs Issues Javascript Limitation Limitations Microsoft Teams ModernScriptEditor NodeJs Node Versioning Numeral.js O365 Office 365 OneDrive Out Of The Box PnP Power Automate PowerShell Pwermissions Rest Endpoint ScriptEditor Send an HTTP Request to SharePoint SharePoint SharePoint Architecture SharePoint Designs SharePoint Modern SharePoint Online SharePoint Tabs ShellScript SPFX SPO Sync Teams Transform JS TypeScript Versioning Workflows

2 thoughts on “Easy Way to Update a SharePoint Content Type”

  1. Hi, thanks for this. I kinda solved my problem with metadata type it was SP.Data.SitePagesItem all the time! MS really have a very good documentation, I can’t really find it!

Leave a Reply to John Vasquez Cancel Reply

Your email address will not be published. Required fields are marked *