Laurence73
Laurence73

Reputation: 1327

GraphServiceClient to create a new SharePoint Online Site

I am trying to create a new subsite of another site in SP Online using the Graph SDK GraphServiceClient. I have successfully authenticated but I cant seem to get a site created - documentation is scarce as are examples so its basically hit and miss and I don't wish to use Graph REST for this purpose. Any help out there? The below code returns a Site object with an error of "invalid request". I'm sure I must be missing some required properties for the new Site object but which ones?

 ItemReference parent = new ItemReference();
 parent.Id = SiteRootForSubsite.Id;
 Site newSite = new Site
         {
            ParentReference = parent,
            Name = SubsiteName,
            WebUrl = "/documentcenter909/mynewsite"
        };

        Site createdSite = await _graphClient.Sites
            .Request()
            .AddAsync(newSite);
 

Upvotes: 0

Views: 738

Answers (1)

Dev
Dev

Reputation: 2464

Unfortunately you don't have the feature to create the site at this point as it only has Read only properties for the site. Being said that you can use the following workaround - can create an office 365 group, then assign owners & members then you will see a new SharePoint Online site will be created automatically.

Upvotes: 1

Related Questions