none
Error While creating Modern Team Site Using CSOM in SharePoint Online RRS feed

  • Question

  • I am trying to creating  to create Modern Team Site in SharePoint Online using CSOM with SharePointPnPCoreOnline component with version 2.20.1711 which is in Beta version  and getting the  Error   App-Only is currently not supported.


    using (var sourceContext = new ClientContext("https://tenant-admin.sharepoint.com/"))
    {
    	sourceContext.Credentials = new SharePointOnlineCredentials(UserName, secure);
    	TeamSiteCollectionCreationInformation modernteamSiteInfo = new TeamSiteCollectionCreationInformation
        {
            Description = "Test modern teamsite description",
            DisplayName = "Test Modern Team Site",
            Alias = "https://tenantname.sharepoint.com/sites/TestModernTeamSite",
            IsPublic = true,
            //Classification="IT"                       
        };
        
        var createModernSite = await context.CreateSiteAsync(modernteamSiteInfo);
    }

    Can anyone help me on this?


    TARUN

    Monday, December 4, 2017 9:14 AM

Answers

  • Hi,

    Currently, app-only ClientContext to provision of modern site is not supported yet. So when creating modern site, we still need to use SharePointOnline credential as the credential of ClientContext.

    In the code snippet above, try to use sourceContext which has been assigned SharePointOnlineCredential and then try again, here is the information from PG of PNP in GitHub:

    Create Modern Site in App Only Context

    Thanks

    Best Regards


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Tuesday, December 5, 2017 7:47 AM

All replies

  • Hi,

    Currently, app-only ClientContext to provision of modern site is not supported yet. So when creating modern site, we still need to use SharePointOnline credential as the credential of ClientContext.

    In the code snippet above, try to use sourceContext which has been assigned SharePointOnlineCredential and then try again, here is the information from PG of PNP in GitHub:

    Create Modern Site in App Only Context

    Thanks

    Best Regards


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Tuesday, December 5, 2017 7:47 AM
  • Hi,

     

    I am checking to see how things are going there on this issue. Please let us know if you would like further assistance.

     

    You can mark the helpful post as answer to help other community members find the helpful information quickly.

     

    Thanks

     

    Best Regards


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Thursday, December 7, 2017 1:07 AM