Skip to content

CreateSiteCollectionAsync returns a 403 error #1390

Answered by ajcaterino
ajcaterino asked this question in Q&A
Discussion options

You must be logged in to vote

I finally got this working. What I found was that I had to remove the HubSiteId assignment from the below code. I then joined the Hub Site after the site collection was created and admins had been assigned. Once I did that I no longer received the 403 Unauthorized error.

var teamSiteToCreate = new TeamSiteWithoutGroupOptions(new Uri(pageParameters.NewSiteUrl), $"{pageParameters.NewSiteTitle}")
{
    SiteDesignId = _dmSettings.SiteDesignId,
    Owner = $"i:0#.f|membership|{_dmSettings.SiteOwners[0]}",
    Language = PnP.Core.Admin.Model.SharePoint.Language.English,
    HubSiteId = await GetHubSiteIdAsync()
};

Replies: 1 comment 7 replies

Comment options

You must be logged in to vote
7 replies
@jansenbe
Comment options

@ajcaterino
Comment options

@jansenbe
Comment options

@ajcaterino
Comment options

Answer selected by jansenbe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants