CreateSiteCollectionAsync returns a 403 error #1390
-
I am using the above code to create a new site collection. This code works in my development environment but not in my production environment. In production I keep getting a 403 Unauthorized error, which I'm leaning towards a permission issue. I am using username/password login as below:
The service user account I am using is a SharePoint Admin account. Any guidance to setting the correct permissions, or what to check for, would be greatly appreciated. Also, the user does not have MFA, but we do use Conditional Access Policies. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 7 replies
-
@ajcaterino : if you're using a user then you need to set "UsingApplicationPermissions" to false, but don't think that's causing the issue. Would recommend doing a Fiddler trace to see what goes wrong, or alternatively grab the actual underlying error information (see https://pnp.github.io/pnpcore/using-the-sdk/basics-errorhandling.html#catching-a-pnp-core-sdk-exception-and-getting-the-exception-details). |
Beta Was this translation helpful? Give feedback.
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.