Forum Discussion
Christopher Johnson
Jun 14, 2017Brass Contributor
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...
Jonathan Cardy
Jan 30, 2019Copper Contributor
Trying to upload an aspx file directly will raise the Access Denied error, but you can use the `Files.AddTemplateFile` method do it: https://docs.microsoft.com/en-us/sharepoint/dev/solution-guidance/modern-experience-customizations-customize-pages
- GlennE888Mar 15, 2019Copper Contributor
Does that work for you? I tried to add the page via Files.AddTemplateFile as mentioned but I get the same Access Denied Error.
- Jonathan CardyMar 16, 2019Copper Contributor
GlennE888 yes it worked for me!
- GlennE888Mar 19, 2019Copper Contributor
Jonathan Cardy Thanks for the response. Is your Sharepoint OnPremise or Office365? I'm trying to upload to Office365 and with the example given I continue to get "Access denied. You do not have permission to perform this action or access this resource."
I'm giving OfficeDevPnP.Core.Pages a try and am having a bit more luck with that.