Skip to main content

Notifications

Power Automate - General Discussion
Answered

Create SharePoint Site Pages automatically with Power Automate when an item is added to OnPrem List

(0) ShareShare
ReportReport
Posted on by 185

Hi I am having the follow error on my flow. What I am trying to do is, whenever an item is added to Sharepoint OnPrem List, create a news page on Sharepoint Online. Here is the error:

 

URI: /_api/web/GetFileByServerRelativeUrl('/sites/spfx/sitepages/NewsTemplate.aspx')/copyto('/sites/spfx/sitepages/Test8.aspx')

 

knishal_0-1664220856569.png

 

 

  • Verified answer
    Expiscornovus Profile Picture
    Expiscornovus 31,144 on at
    Re: Create SharePoint Site Pages automatically with Power Automate when an item is added to OnPrem List

    Hi @knishal,

     

    Did you add the expression in the File Identifier field in the same way as in the animation below?

     

    Can you also double check that your title/name field has the same internal name as in my expression. I used Title_x002f_Name. Your field could be different.

     

    If it is different you also need to update the expression so that it will be using your specific internal field name.

     

    You can check that via the peek code in a compose. Or just hover over it. That is in the second part of the same animation below.

     

    PeekCode_addExpression.gif

  • knishal Profile Picture
    knishal 185 on at
    Re: Create SharePoint Site Pages automatically with Power Automate when an item is added to OnPrem List

    Tried that, didnt work too 😞 Same error.

  • Expiscornovus Profile Picture
    Expiscornovus 31,144 on at
    Re: Create SharePoint Site Pages automatically with Power Automate when an item is added to OnPrem List

    Hi @knishal,

     

    Can you add the previous code snippet via the expression editor/tab instead of pasting it as plain text?

  • knishal Profile Picture
    knishal 185 on at
    Re: Create SharePoint Site Pages automatically with Power Automate when an item is added to OnPrem List

    @Expiscornovus tried that and got the same error. Did i miss something:

    knishal_0-1664295505676.png

     

  • Expiscornovus Profile Picture
    Expiscornovus 31,144 on at
    Re: Create SharePoint Site Pages automatically with Power Automate when an item is added to OnPrem List

    Hi @knishal,

     

    I would use some encoding in the File Identifier.

     

    You could use the encodeUriComponent function for this.

     

    In your setup that would be probably something like below:

     

    encodeuricomponent(concat('/SitePages/', triggerOutputs()?['body/Title_x002f_Name'], '.aspx'))

     

     

    fileidentifier_encoding.png

  • knishal Profile Picture
    knishal 185 on at
    Re: Create SharePoint Site Pages automatically with Power Automate when an item is added to OnPrem List

    @ExpiscornovusI see the issue and it works now. I will accept that as a solution. I have another Issue and dont want to create another post. Moving on from that step, I have an issue with getting the file meta data. 

     

    Flow:

    knishal_1-1664289260350.png

     

    Error:

    knishal_0-1664289184118.png

     

    Any idea on how I can resolve this?

     

     

  • Expiscornovus Profile Picture
    Expiscornovus 31,144 on at
    Re: Create SharePoint Site Pages automatically with Power Automate when an item is added to OnPrem List

    Hi @knishal,

     

    It looks like it cannot find the original page, which it tries to copy. The NewsTemplate page does exist within the spfx site, correct? 

     

    And another check. Are you using the same site name in the Uri value as in the Site Address dropdown?

     

    samesiteinaddress.png

  • knishal Profile Picture
    knishal 185 on at
    Re: Create SharePoint Site Pages automatically with Power Automate when an item is added to OnPrem List

    Hi @Expiscornovus I tried that and its giving me the same error:

    knishal_0-1664280351092.png

    "message""Server relative urls must start with SPWeb.ServerRelativeUrl\r\nclientRequestId: 2d8e2338-3ec9-43f3-8768-ae4c19b6a901\r\nserviceRequestId: ec0f69a0-1014-d000-6ce6-0883805a103e",
  • Expiscornovus Profile Picture
    Expiscornovus 31,144 on at
    Re: Create SharePoint Site Pages automatically with Power Automate when an item is added to OnPrem List

    Hi @knishal,

     

    Can you try this for the URI:

    _api/web/getfilebyserverrelativeurl('/sites/spfx/SitePages/NewsTemplate.aspx')/copyto(strnewurl='/sites/spfx/SitePages/Test8.aspx',boverwrite=false)

     

    I see the copyto method also has strnewurl & boverwrite parameters:

    https://learn.microsoft.com/en-us/previous-versions/office/developer/sharepoint-rest-reference/dn450841(v=office.15)#copyto-method

     

    Below is an example in a Send an HTTP request to SharePoint action.

     

    copyto_restapi.png

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

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,666

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,996

Leaderboard