Overview
This blog will help you create an Automation of Modern Page Creation in SharePoint Using Power Automate.
We will use email receiving as the trigger. But we can use SharePoint List as well.
Step 1 - Create a Template
A page template needs to be created as this will be used as a template for all the new pages that we will create using the automation.
For the demo we will create a simple page with text webpart where we will add all the required content and name the template as blanktemplate
Step 2 - Create a Power Automate Flow
- We will create an automated flow triggered when an email is received from a particular email id
- [Action :- send an HTTP request to SharePoint] Now the first step is to create the page,
We will use copy to end point to create the page from the templateUri :- _api/web/getfilesbyserverrelativeurl('/sitepages/templates/blanktemplate.aspx')/copyto(strnewurl='/sitepages/@{triggerBody()?['subject']}.aspx',bOverwrite=true)
- [Action :- Get file metadata] We will require the Id of the page which was created for checking out the page and
updating the content of the page so the next step is to add get file metadataFile Identifier :- SitePages%2f@{triggerBody()?['subject']}.aspxNote
We will have to replace "/" with its uri encoded value "%2f"
- [Action :- send an HTTP request to SharePoint] We will need to check out the page so that we can add content to the page
Uri :- _api/sitepages/pages(@{body('Get_file_metadata')?['ItemId']})/checkoutpage
- [Action :- Compose] To use the HTML data which is coming from the Mail we would require to change the data.
- Replace double quotes(") in HTML to (\\\") so that it can be used in the JSON object while saving the data
-
- replace(uriComponent(triggerBody()?['body']),'%22','%5C%5C%5C%22')
- Replace white space in HTML with blank text
-
- uriComponentToString(replace(outputs('Compose'),'%0D%0A',''))
- [Action :- send an HTTP request to SharePoint] we will now need to save the page as a draft and send the JSON object in the body.
Uri :- _api/sitepages/pages(@{body('Get_file_metadata')?['ItemId']})/savepageasdraft
- [Action :- send an HTTP request to SharePoint] we will now publish the page using the below endpoint.
Uri :- _api/sitepages/pages(@{body('Get_file_metadata')?['ItemId']})/Publish

Step 3
How to get JSON for saving the page
- Edit any existing page created from template
- Click on publish (open the developer tool by pressing F12)
- Got to the network tab in the developer tool and search for SavePage
Click on the request at the bottom. We will get request payload which will be used for the request body.

Outcome
Received Email

Created Page


illy mahn2Posted Mar 9, 2026, 10:05 PM
Have you worked with images web part components ?
Winter PricePosted Jul 8, 2025, 8:31 PM
I am stuck on the last two steps: [Action :- send an HTTP request to SharePoint] we will now need to save the page as a draft and send the JSON object in the body.Uri :- _api/sitepages/pages(@{body('Get_file_metadata')?['ItemId']})/savepageasdraft[Action :- send an HTTP request to SharePoint] we will now publish the page using the below endpoint. Uri :- _api/sitepages/pages(@{body('Get_file_metadata')?['ItemId']})/Publish Neither are authorized. Am I doing something wrong?
Arjit SoniPosted Aug 11, 2024, 8:49 AM
Hi Kunj, Nice article. Can you please share the JSON clear screenshot again, where to change the HTML content in JSON ?
Seth KwitkoPosted Dec 26, 2023, 5:02 PM
Hi Kunj. Can you post a better picture of the flow that you posted in Step 7? It's difficult to read, and the instructions do not clearly state what dynamic data should be placed within the JSON. Thank you.
Oliver ScottPosted Feb 7, 2023, 4:37 AM
Hi Kunj, I am struggling with the compose inputs, are you able to post exactly what is in your inputs? I have got Compose 1: replace(uriComponent(triggerBody()?['body']),'%22','%5C%5C%5C%22') Compose 2: uriComponentToString(replace(outputs('Compose'),'%0D%0A','')) however this is returning a bunch of random code with the body text in it randomly on my sitepage?
Raphael IlliPosted Jun 15, 2022, 5:32 AM
Dear Kunj, thanks for your post! very helpful. is possible to attach a document to the same page as part of this flow? what would the http request look like (URI, body, headers)?
Amit SaraswatPosted May 23, 2022, 4:22 PM
Can we update the First Published Date using Power Automate?
SHIV KUMARPosted Aug 17, 2021, 4:16 AM
Please see Compose 2 output that I followed step 2 point 5 : <html><head><meta http-equiv=\\\"Content-Type\\\" content=\\\"text/html; charset=utf-8\\\"><meta content=\\\"text/html; charset=us-ascii\\\"><meta name=\\\"Generator\\\" content=\\\"Microsoft Word 15 (filtered medium)\\\"><style><!--@font-face {font-family:\\\"Cambria Math\\\"}@font-face {font-family:Calibri}p.MsoNormal, li.MsoNormal, div.MsoNormal {margin:0in; margin-bottom:.0001pt; font-size:11.0pt; font-family:\\\"Calibri\\\",sans-serif}a:link, span.MsoHyperlink {color:#0563C1; text-decoration:underline}a:visited, span.MsoHyperlinkFollowed {color:#954F72; text-decoration:underline}p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph {margin-top:0in; margin-right:0in; margin-bottom:0in; margin-left:.5in; margin-bottom:.0001pt; font-size:11.0pt; font-family:\\\"Calibri\\\",sans-serif}span.EmailStyle17 {font-family:\\\"Calibri\\\",sans-serif; color:windowtext}.MsoChpDefault {font-family:\\\"Calibri\\\",sans-serif}@page WordSection1 {margin:1.0in 1.0in 1.0in 1.0in}div.WordSection1 {}ol {margin-bottom:0in}ul {margin-bottom:0in}--></style></head><body lang=\\\"EN-US\\\" link=\\\"#0563C1\\\" vlink=\\\"#954F72\\\"><div class=\\\"WordSection1\\\"><p class=\\\"MsoNormal\\\">This is a Test Email with all content</p><p class=\\\"MsoNormal\\\"> </p><p class=\\\"MsoNormal\\\"><b>Bold Text</b></p><p class=\\\"MsoNormal\\\"><i>Italic Text</i></p><p class=\\\"MsoNormal\\\"><u>Underline Text</u></p><p class=\\\"MsoNormal\\\"><u><span style=\\\"text-decoration:none\\\"> </span></u></p><p class=\\\"MsoNormal\\\"><span style=\\\"color:red\\\">Text with color</span></p><p class=\\\"MsoNormal\\\"> </p><ol start=\\\"1\\\" type=\\\"1\\\" style=\\\"margin-top:0in\\\"><li class=\\\"MsoListParagraph\\\" style=\\\"margin-left:0in\\\">Numbering</li><li class=\\\"MsoListParagraph\\\" style=\\\"margin-left:0in\\\">For testing</li></ol></div></body></html>
SHIV KUMARPosted Aug 17, 2021, 4:11 AM
Hi Kunj, Please upload the working flow here as image shown here is not completely visible. I also tried to create the flow but for saveasdraft, i am getting as { "error": { "code": 502, "source": "flow-apim-europe-001-francecentral-01.azure-apim.net", "clientRequestId": "391f7cfc-f64f-4d65-8b6c-bdda4bd55483", "message": "BadGateway", "innerError": { "status": 502, "message": "There was an error deserializing the object of type Microsoft.SharePoint.Publishing.SitePageFieldsData. Encountered invalid character '\t'.\r\nclientRequestId: 391f7cfc-f64f-4d65-8b6c-bdda4bd55483\r\nserviceRequestId: 7c47e69f-c006-3000-0ead-c1f40461a9d6", "source": "https://[domain].sharepoint.com/teams/TestComm/_api/sitepages/pages(8)/savepageasdraft", "errors": [ "-1", "System.Runtime.Serialization.SerializationException" ] } } }
Matt BerryPosted May 27, 2021, 9:52 PM
Hi kunj, great Flow but please can you share the Syntax around the Output in the request Body?
Nicholas WorrellPosted Mar 19, 2021, 9:26 PM
This is extremely useful, much respect to you for sharing.
ANKIT singhPosted Feb 22, 2021, 10:54 AM
Hi Kunj Thanks for your post. I am facing issue while sending http post request(2nd step). Its giving error : Cannot find resource for the request getfilesbyserverrelativeurl.clientRequestId: bdb6e708-c9a4-4761-8d88-652d722e4f47
Nausheen Hanan HussainPosted Oct 20, 2020, 10:38 PM
Good one Kunj.
Vijai Anand RamalingamPosted May 13, 2020, 9:55 AM
Nice Article!!! Keep contributing