POST https://graph.microsoft.com/beta/sites
Content-Type: application/json
{
"name": "Communication Site Test",
"webUrl": "https://contoso.sharepoint.com/sites/commsite1",
"locale": "en-US",
"shareByEmailEnabled": false,
"description": "Test Site Description",
"template": "sitepagepublishing",
"ownerIdentityToResolve": {
"email": "ryan@contoso.com"
}
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models;
using Microsoft.Kiota.Abstractions.Serialization;
var requestBody = new Site
{
Name = "Communication Site Test",
WebUrl = "https://contoso.sharepoint.com/sites/commsite1",
Description = "Test Site Description",
AdditionalData = new Dictionary<string, object>
{
{
"locale" , "en-US"
},
{
"shareByEmailEnabled" , false
},
{
"template" , "sitepagepublishing"
},
{
"ownerIdentityToResolve" , new UntypedObject(new Dictionary<string, UntypedNode>
{
{
"email", new UntypedString("ryan@contoso.com")
},
})
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Sites.PostAsync(requestBody);
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewSite()
name := "Communication Site Test"
requestBody.SetName(&name)
webUrl := "https://contoso.sharepoint.com/sites/commsite1"
requestBody.SetWebUrl(&webUrl)
description := "Test Site Description"
requestBody.SetDescription(&description)
additionalData := map[string]interface{}{
"locale" : "en-US",
shareByEmailEnabled := false
requestBody.SetShareByEmailEnabled(&shareByEmailEnabled)
"template" : "sitepagepublishing",
ownerIdentityToResolve := graph.New()
email := "ryan@contoso.com"
ownerIdentityToResolve.SetEmail(&email)
requestBody.SetOwnerIdentityToResolve(ownerIdentityToResolve)
}
requestBody.SetAdditionalData(additionalData)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
sites, err := graphClient.Sites().Post(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
Site site = new Site();
site.setName("Communication Site Test");
site.setWebUrl("https://contoso.sharepoint.com/sites/commsite1");
site.setDescription("Test Site Description");
HashMap<String, Object> additionalData = new HashMap<String, Object>();
additionalData.put("locale", "en-US");
additionalData.put("shareByEmailEnabled", false);
additionalData.put("template", "sitepagepublishing");
ownerIdentityToResolve = new ();
ownerIdentityToResolve.setEmail("ryan@contoso.com");
additionalData.put("ownerIdentityToResolve", ownerIdentityToResolve);
site.setAdditionalData(additionalData);
Site result = graphClient.sites().post(site);
const options = {
authProvider,
};
const client = Client.init(options);
const site = {
name: 'Communication Site Test',
webUrl: 'https://contoso.sharepoint.com/sites/commsite1',
locale: 'en-US',
shareByEmailEnabled: false,
description: 'Test Site Description',
template: 'sitepagepublishing',
ownerIdentityToResolve: {
email: 'ryan@contoso.com'
}
};
await client.api('/sites')
.version('beta')
.post(site);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Models\Site;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new Site();
$requestBody->setName('Communication Site Test');
$requestBody->setWebUrl('https://contoso.sharepoint.com/sites/commsite1');
$requestBody->setDescription('Test Site Description');
$additionalData = [
'locale' => 'en-US',
'shareByEmailEnabled' => false,
'template' => 'sitepagepublishing',
'ownerIdentityToResolve' => [
'email' => 'ryan@contoso.com',
],
];
$requestBody->setAdditionalData($additionalData);
$result = $graphServiceClient->sites()->post($requestBody)->wait();
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.models.site import Site
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = Site(
name = "Communication Site Test",
web_url = "https://contoso.sharepoint.com/sites/commsite1",
description = "Test Site Description",
additional_data = {
"locale" : "en-US",
"share_by_email_enabled" : False,
"template" : "sitepagepublishing",
"owner_identity_to_resolve" : {
"email" : "ryan@contoso.com",
},
}
)
result = await graph_client.sites.post(request_body)