Forum Discussion

Christopher Johnson's avatar
Christopher Johnson
Brass Contributor
Jun 14, 2017

Access denied in SharePoint SitePages library

I am trying to create modern SharePoint pages programmatically in SitePages libraries on groups-based sites.

 

I first attempted doing so with PowerShell, then with Flow and finally confirmed via a direct call to the REST service that it is not supported-- in each case, the result is the same: Access Denied.

 

Is there a policy on modern SharePoint SitePages libraries that prevents users-- even users with full control of the site-- from creating content via REST?

 

Below is the result of the REST post to /files/add method:

{ "status": 403, "message": "Access denied. You do not have permission to perform this action or access this resource.", "source": "https://<myTenantUrl>.sharepoint.com/sites/<siteName>/_api/web/GetFolderByServerRelativeUrl('/sites/Safety/SitePages')/files/add(url='Test9.aspx',%20overwrite='true')", "errors": [ "-2147024891", "System.UnauthorizedAccessException" ] }

"-2147024891", "System.UnauthorizedAccessException" ] }

 

This appears related to the same issue that I posted to the PnP GitHub repo, in which the same occurs when attempting to upload a page via PowerShell.

 

Per this post by Vesa Juvonen, the client object model supports adding pages programmatically and there are PnP extension methods to do so. 

 

TL;DR: Just want to confirm that the same is NOT possible via REST at this time as it will affect the architecture of a solution I'm writing.

 

Resources