Dec 22 2017 01:07 AM
I'm trying to create a Modern Experience page from a Provider Hosted app in C# and add webparts to it.
The ClientSidePage is created ok and i can add sections to it with ClientSidePage.AddSection(CanvasSectionTemplate.OneColumn, s.Section.Order)
The problem arises when i try to add webparts to the page. Nothing happens when i call ClientSidePage.AvailableClientSideComponents(). The same problem arises when calling ClientSidePage.InstantiateDefaultWebPart(DefaultClientSideWebParts.Events)
I get no error, the code just does not execute. After a while the code seems to timeout, still without an exception. I can navigate to the page and edit it. Now i see my sections but no webparts ofcourse.
Sometimes, maybe 1 out of 10 times, the code works and the webparts are added to the page.
Dec 28 2017 11:23 PM
Hi,
Please verify if the DenyAddAndCustomizePages is set to false or 0
Set-SPOSite -Identity https://<yourdomain>.sharepoint.com -DenyAddAndCustomizePages $false
Jan 04 2018 07:01 AM - edited Jan 04 2018 07:08 AM
Hi
The DenyAddAndCustomizePages is set to Disabled.
I ditched the built in AvailableClientSideComponents function and wrote my own using the /_api/web/GetClientSideWebParts API instead and now it's working as expected.