Timeout (?) calling ClientSidePage.AvailableClientSideComponents when adding webparts

Copper Contributor

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.



2 Replies



Please verify if the DenyAddAndCustomizePages is set to false or 0

Set-SPOSite -Identity https://<yourdomain>.sharepoint.com -DenyAddAndCustomizePages $false



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.