0

I am using OfficeDevPnP package to create new Modern Team No Group site collection but i got below error

"You need to set the owner in App-only context". See the function execution logs for additional details. ---> System.Exception: You need to set the owner in App-only context at OfficeDevPnP.Core.Sites.SiteCollection.d__8.MoveNext()

Here is my code,

using (ClientContext context = authManager.GetAppOnlyAuthenticatedContext("TenanatUrl", "ClientId", "ClientSecrete"))
{
    var creationInformation = new OfficeDevPnP.Core.Sites.TeamNoGroupSiteCollectionCreationInformation(siteUrl, siteName, userName);
    var results = await context.CreateSiteAsync(creationInformation);
}

I am using AppOnly Context here and also provided tenant full control permissions.

1

The permissions are correct, but in App-only context you need to pass the owner name.

This method, TeamNoGroupSiteCollectionCreationInformation(siteUrl, siteName, userName) accepts 3 params the last of which is description. But you need to pass the owner value which is necessary in apponly context, so modify the code as below:

var creationInformation = new TeamNoGroupSiteCollectionCreationInformation
{
    Url = siteUrl,
    Title = siteName,
    Owner = userName // login name of a user
};

var results = await context.CreateSiteAsync(creationInformation);
1
  • Thanks!! It worked..!
    – SBP
    Jul 10 '20 at 6:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.