Access Denied Error When Creating Or Copying SharePoint Page Using Power Automate

Requirement

I want to copy an existing page whenever a new item is created in SharePoint list using Power Automate. The following triggers and actions are used to achieve this requirement.

Trigger

When an item is created.

Action

Send an HTTP request to SharePoint.

Issue

I was getting the following error while trying to execute this flow. I was having site collection administrator access but still I was getting the below error.

Access denied. You do not have permission to perform this action or access this resource. clientRequestId: c9f0c906-2e13-4894-8137-2c21ed5fbbd3 serviceRequestId: d4a3519f-b06a-b000-c99f-e1e820aac547

Access Denied Error When Creating Or Copying SharePoint Page Using Power Automate

I figured out that this issue was occurring because of a missing “/” in the relative URL.

Access Denied Error When Creating Or Copying SharePoint Page Using Power Automate

Solution

Make sure relative URL’s are correct in order to avoid any such issues.

/_api/web/getfilebyserverrelativeurl('/sites/practicespfx/SitePages/PageTemplate.aspx')/copyto('/sites/practicespfx/SitePages/@{triggerBody()?['Title']}.aspx')