16 Replies to “SharePoint Online REST APIs (Part III): Pages”

  1. Hi,

    Firs of all thanks for the synthesized iformation. I’m trying to create a page with Power Automate using the last two endpoints in your list. First one is to create the page and the second to populate the page with the data. The flow goes without errors but the end result is a copy of the template page with chaged name. The content is unchanged. More info about my problem can be found here https://powerusers.microsoft.com/t5/Building-Flows/Send-http-request-to-SharePoint/td-p/1323311. Any suggestions are welcome. Thanks in advance.

    1. Hi, thanks for reading! API calls can be tricky to troubleshoot (especially when it’s saying everything is fine). I’ve had issues in the past where a page wouldn’t change if my HTML was not right (SharePoint can be picky about the littlest change). I have a post that I need to write about this process, however, it’s quite complicated and frankly I just keep putting it off. I noticed that you are not referencing a template file in your code, but appears to be another SharePoint page. Also are you going to the Developer Tools in your browser and getting the code from there? This post outlines the process and might be helpful if you haven’t seen it before (step 3 outlines the Dev Tools step): https://www.c-sharpcorner.com/blogs/automate-modern-sharepoint-page-creation-using-power-automate

  2. Hi again,

    I have read this article before and it is quite similar to the youtube video I posted in the other topic. Today I tried to run the request manually with the help of little bit of JS. In the console I got the error that the security validation of the page was invalid. The recommended approach in such cases is to add the X-requestdigest property in the header. However I have no idea how to do that in power automate.

    1. So I was able to get the flow working with static hard coded content, but not with dynamic. It turns out that I was using wrong ID and that was the reason why nothing was changed. Now the problem is how to get the content from the word file and put it on the page. The PageContent option from GetFileContent is taking too much time and eventually the flow fails because the session is ended. Any Ideas why this happens?

      1. As far as I’m aware, Power Automate returns the data from Word as binary. Depending on how big or complicated your document is, this might cause the action to time out. To read a document, you would most likely need to use the AI tools in Azure.
        https://azure.microsoft.com/en-us/services/form-recognizer/#overview
        https://powerusers.microsoft.com/t5/Using-Flows/Is-there-any-method-to-red-content-of-word-and-pdf-file-from/m-p/284166/highlight/false#M6914
        EDIT: I found this post which explains how you can get the text. It’s not straight forward, but looks like you might be able to extract the text by XML elements, then manipulate it from there: https://www.tachytelic.net/2021/05/power-automate-extract-text-from-word-docx-file/

  3. Thank you so much for this valuable information. Right now I’am being able to extract the information and all the flows pass except the last one where I am putting the output of the compose into the request body and want to save the page as a draft. Is it possible because the output is array and this messes up the last step? The word file I’m using for testing has only one line of text, so there is not so much info.

  4. If anyone is interested the output of the compose expression should be represented with join(outputs(‘Compose’),’;’) so that it can be put in the body of the request.

  5. hi, i am unable to promote my page to news using the api call. it says the expression status code 400, even though its correctly getting the page metadata. Why would this be the case? This would be the last step in my flow and i cant get it to work!

  6. Thank you for your valuable posts, they helped me a lot.
    I was using Inspect element -> Request Payload to change something in my SharePoint page then I used the save page as draft and publish API. But I need to get the Request Payload with an API too in order to change the CanvasContent, I tried with ‘Get page content’ API referenced in one of your articles, but I get the HTML and I can convert only to text not as the JSON format I get with the request payload. I need this because some of the canvas content can be changed manually with edit click, and some parts will be changed within the flow, so I need to get the present content and not to use the static request payload I copied in my flow.
    Any idea how to manage this, thank you in advance!!

  7. Thank you so much for putting together all that info—it’s been really helpful.

    Currently, I am working on sending an HTTP request to post a comment on a SharePoint page, specifically with the intention of mentioning someone to trigger an email notification. In essence, I am attempting an HTTP POST with the use of @Mention{}, ideally identifying the person by email. While there are numerous resources available on posting comments in SharePoint lists, I have encountered difficulty finding information specifically related to commenting on Site Pages.

    I have successfully sent a request to Site Pages using the URI: _api/web/lists/getbytitle(‘Site Pages’)/items(id)/Comments. However, the success is only partial—the comment appears, but the @Mention{} functionality does not seem to activate. I am confident that there must be an alternative method, distinct from treating Site Pages as lists as indicated in the above URI.

    Appreciate any hint or advise. Thank you once again for your time and consideration.

Leave a Reply

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