1

Is there any way to provision a SharePoint online team sites using rest API or Graph API?

Thanks in advance...

0

Are you looking for modern or classic team sites. For instance when you create an Office 365 group, a sharepoint modern team site gets automatically provisioned for the group. You can create groups through Graph API. You also have the option of using PnP projects such as PnP Powershell to create groups and modern team sites. Here is a reference to provision modern team sites programatically : https://docs.microsoft.com/en-us/sharepoint/dev/solution-guidance/modern-experience-customizations-provisioning-sites

Here is another good reference : https://gautamdsheth.wordpress.com/2017/10/16/create-o365-groups-with-csom-c/

1

You could use PnP PowerShell to provision the Modern Team Site:

var targetTenantUrl = "https://[tenant].sharepoint.com/";

using (var context = new ClientContext(targetTenantUrl))
{
    context.Credentials = OfficeDevPnP.Core.Utilities.CredentialManager.GetSharePointOnlineCredential("[Name-of-Your-Credentials]");

    // Create new "modern" team site at the url
    // https://[tenant].sharepoint.com/sites/mymodernteamsite
    var teamContext = await context.CreateSiteAsync(
        new TeamSiteCollectionCreationInformation
        {
            Alias = "mymodernteamsite", // Mandatory
            DisplayName = "displayName", // Mandatory
            Description = "description", // Optional
            Classification = "classification", // Optional
            IsPublic = true, // Optional, default true
        });
    teamContext.Load(teamContext.Web, w => w.Url);
    teamContext.ExecuteQueryRetry();
    Console.WriteLine(teamContext.Web.Url);
}

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.