web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Unanswered

How to create and modify SharePoint pages with Power Automate

(0) ShareShare
ReportReport
Posted on by

Hi. I am trying to get Power Automate to modify a SharePoint page; for instance, changing the URL on a button, or changing a web part, etc. I would also like to create pages. I assume I will need to use the SharePoint HTTP action to do this, but I have no idea how to navigate the REST API to figure out what URIs and request bodies I need.

 

Any help is greatly appreciated.

I have the same question (0)
  • eliotcole Profile Picture
    4,339 Moderator on at
    Re: How to create and modify SharePoint pages with Power Automate

    Hi, @ameyer24, you'll need to rely on the SitePages API for ease of use, here, I think.

     

    Initial Starter For Ten

    Just a little information to get you started ... if you are doing one, very specific thing, you may be able to keep things simple, but you'll see the complexity when you get to the HTML part of things.

     

    Knowing the webpart ID that you want to update will probably be the key thing to know for most updates, too.

     

    API Info

    I've placed this in the spoiler as it is purely for reference:

    Spoiler (Highlight to read)

    There are two resources that I always find useful:

    1. Microsoft API References - These are the two main Microsoft pages for the SharePoint API
    2. SharePoint REST API Metadata Explorer - This is SUPER helpful with about 95-99 percent of all the endpoints there are to know about on there!

    There is more buried on the Microsoft documentation site, in older versions, or for on-prem stuff ... but it's not the easiest resource.

    There are two resources that I always find useful: Microsoft API References - These are the two main Microsoft pages for the SharePoint API Microsoft SharePoint API 1.0 - This is the main resource that you will have from MS Microsoft SharePoint API 2.0 (graph)  - This is useful to make your calls more modern and future proof as everything moves to the graph API SharePoint REST API Metadata Explorer - This is SUPER helpful with about 95-99 percent of all the endpoints there are to know about on there! There is more buried on the Microsoft documentation site, in older versions, or for on-prem stuff ... but it's not the easiest resource.

     

    First Get The Page

    Firstly, if you were (for example) to get the details of the home page, lets say you have a SharePoint HTTP action named:

    HTTP_GET_PageJSON

    Then you would want to select the site, set the 'Method' to GET, and then use something like this in the 'Uri' field:

    _api/sitepages/Pages/GetById(1)

    That would provide a JSON response, and the key value that you want is the 'CanvasContent1' value.

     

    I can't remember if adding the following query helps things, so maybe also keep this in mind:

    _api/sitepages/Pages/GetById(1)?env=Embedded

     

    Then Convert CanvasContent1

    However, that value is JSON but not kept in JSON format. So you will need an action after the HTTP action to decode that with:

    json(body('HTTP_GET_PageJSON')?['d/CanvasContent1'])

    I tend to use an Array type Variable for this.

     

    Now Update Page

    The final thing you will need to do to modify a page is to update it. This uses the same call as getting the page, and that just needs to be sent with the 'PATCH' method. Again, if you need the query, include it.

     

    You probably don't need specific Accept and Content-type headers here, however if you do use verbose ODATA values for those, then you just need to include a metadata key and object for the body of this action.

     

    Other Actions

    You may need to check-in, check-out, etc, and other stuff with your page, or set the properties, or publishing status. Try to attack those parts separately in your head. Get the updating down first, and you'll get the rest easily enough.

     

    Moving Forward

    From here on out, I can't really guide you any more, as your question is a more broad question. Which is fine, just gives you some fun to have! 🙂

     

    Raise Something Specific

    If you already have a flow and a specific purpose, then perhaps raise a new question for what you specifically need to get accomplished that you cannot work out yourself. Don't edit this one, as it might get a little mired.

     

    If you do, do try make sure to embed (not attach, not everyone can download files) some screenshots of the designer view of your flow into the question. This provides context that assists others recognise their problem in yours, and helpers to have more of an idea of how to help you.

     

    If you are getting specific errors, then try to include imagery of the run results, too. Heck, if you have example data that could help folks ... even better! 😅

     

    Remember that you can always obfuscate (blot out / blur / whatever) anything sensitive, so don't worry about that too much.

     

    You may also be better off asking in a SharePoint community / online area, as they'll give you API specific help on this. You can just ignore all the permissions stuff, since you're doing it in Power Automate. 😉

     

    Finally

    Again, this is going to be advanced as you will want to ensure that you nail the HTML that you're pushing through, as Modern SharePoint Online is reasonably strict.

     

    For example, I recently put together the following and this is just the Scope for deciding the content of a team people part when someone is added / removed from the group!

    Spoiler (Highlight to read)
    example-update-people-web-part.png

     

     

     

    Another example; I used this method recently and needed to ensure that the Rich Text that people were entering in a list elsewhere was responsibly being displayed on the page in the fonts (etc) that are appropriate to that page. So I had to strip all customisations of the text beyond the basic heaviness or emphasis, therein. A *lot* of logic work.

  • BP-WS Profile Picture
    34 on at
    How to create and modify SharePoint pages with Power Automate
    Hi @eliotcole, thank you very much for posting something like this - very helpful. I do however have an issue when trying to follow your steps.
     
    I'm trying to do a very basic process:
    1. Get the page, even if ID is hard coded, like your example.
    2. Amend the JSON - e.g. change a quick link that is already in the page
    3. Patch the whole page back to overwrite the existing page content, but now with amended links and such via the JSON amended
     
    Please would you be able to provide more info around the "Now Update Page" section - as when I've simply got the outputs of the initial HTTP and put this into a compose as JSON - as per your guide - this is giving me the following error on my Patch HTTP request: "Invalid JSON. A comma character ',' was expected in scope 'Object'. Every two elements in an array and properties of an object must be separated by commas."

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Chiara Carbone – Community Spotlight

We are honored to recognize Chiara Carbone as our Community Spotlight for November…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 722 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 461 Moderator

#3
developerAJ Profile Picture

developerAJ 283

Last 30 days Overall leaderboard