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...
GlennE888
Mar 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 Cardy
Mar 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.
- Jonathan CardyMar 19, 2019Copper ContributorI'm using Office365. I haven't tried it on premise as of yet but I believe the solution is the same. PnP does actually use this same method - compare your code to that. Source is here - search for 'AddTemplateFile': https://github.com/SharePoint/PnP-Sites-Core/blob/master/Core/OfficeDevPnP.Core/Pages/ClientSidePage.cs
- GlennE888Apr 03, 2019Copper Contributor
Thanks, I got it working, I was pointing to the folder where I wanted to place the file instead of pointing to the file I wanted to be created. So I now am able to create pages on the site but still having problems with the pages created.
If I create the page in Site Pages, then try to edit them from the UI I get:"You cannot edit this page
We're sorry, we encountered an unexpected error. Please try again, if the problem persists please contact your Administrator."
If I create the page in WikiPageLib, I can't even load the file. Attempting to load the file I get:
"Sorry, something went wrong
NoComponentId"
Any ideas?
Thanks.