Jun 14 2017 11:43 AM - edited Jun 14 2017 11:44 AM
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:
"-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.
Jun 15 2017 11:25 AM
Just tried this on my tenant, I can upload via REST to Site Pages on classic sites, I get the same behaviour as you describe when trying on a Modern site.
Jun 15 2017 11:30 AM
Mar 21 2018 11:15 AM
I had the same issue trying with CSOM... Any solution?
What I saw in the permissions is that there is a DENY ... Another indicator that something is blocking us...
Jan 30 2019 04:43 AM
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-c...
Mar 15 2019 10:12 AM
Does that work for you? I tried to add the page via Files.AddTemplateFile as mentioned but I get the same Access Denied Error.
Mar 16 2019 02:43 AM
@GlennE888 yes it worked for me!
Mar 19 2019 07:14 AM
@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.
Mar 19 2019 07:19 AM
Apr 03 2019 12:53 PM
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.
Apr 04 2019 01:48 AM
@GlennE888 Sounds like the source of the page might be messed up? It might be worth opening a new ticket.