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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Create SharePoint Site...
Power Automate
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

 

 

Categories:
I have the same question (0)
  • Expiscornovus Profile Picture
    33,757 Most Valuable Professional on at

    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

  • knishal Profile Picture
    185 on at

    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
    33,757 Most Valuable Professional on at

    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
    185 on at

    @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
    33,757 Most Valuable Professional on at

    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
    185 on at

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

    knishal_0-1664295505676.png

     

  • Expiscornovus Profile Picture
    33,757 Most Valuable Professional on at

    Hi @knishal,

     

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

  • knishal Profile Picture
    185 on at

    Tried that, didnt work too 😞 Same error.

  • Verified answer
    Expiscornovus Profile Picture
    33,757 Most Valuable Professional on at

    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

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 250 Super User 2026 Season 1

#2
Expiscornovus Profile Picture

Expiscornovus 222 Most Valuable Professional

#3
Haque Profile Picture

Haque 174

Last 30 days Overall leaderboard