名前空間: microsoft.graph
重要
Microsoft Graph の /beta バージョンの API は変更される可能性があります。 実稼働アプリケーションでこれらの API を使用することは、サポートされていません。 v1.0 で API を使用できるかどうかを確認するには、Version セレクターを使用します。
新しい SharePoint サイトを作成 します。
アクセス許可
この API の最小特権としてマークされているアクセス許可またはアクセス許可を選択します。
アプリで必要な場合にのみ、より高い特権のアクセス許可またはアクセス許可を使用します。 委任されたアクセス許可とアプリケーションのアクセス許可の詳細については、「アクセス許可の種類」を参照してください。 これらのアクセス許可の詳細については、「アクセス許可のリファレンス」を参照してください。
| アクセス許可の種類 |
最小特権アクセス許可 |
より高い特権のアクセス許可 |
| 委任 (職場または学校のアカウント) |
Sites.Create.All |
Sites.FullControl.All |
| 委任 (個人用 Microsoft アカウント) |
サポートされていません。 |
サポートされていません。 |
| アプリケーション |
Sites.Create.All |
Sites.FullControl.All |
HTTP 要求
POST /sites
| 名前 |
説明 |
| Authorization |
ベアラー {token}。 必須です。
認証と認可についての詳細をご覧ください。 |
| Content-Type |
application/json. 必須です。 |
要求本文
要求本文で、 サイト オブジェクトの JSON 表現を指定します。
サイトを作成するときに、次のプロパティを指定できます。
| プロパティ |
型 |
説明 |
| description |
String |
サイトの説明テキスト。
baseItem から継承されます。 |
| ロケール |
文字列 |
サイトの言語設定。 |
| name |
String |
サイトの名前。
baseItem から継承されます。 省略可能。 |
| ownerIdentityToResolve |
identityInput |
サイトの作成時にのみ提供されるサイト所有者。 省略可能。 |
| shareByEmailEnabled |
ブール型 |
サイトとそのコンテンツを電子メールで共有できるかどうかを決定します。 省略可能。 |
| template |
siteTemplateType |
サイトに適用されるテンプレートを指定します。 使用可能な値: sitepagepublishing、group、sts、unknownFutureValue。 省略可能。 |
| webUrl |
String |
サイトの作成時にのみ指定できるサイトの URL。
baseItem から継承されます。 省略可能。 |
応答
成功した場合、このメソッドは 202 Created 応答コードと応答本文の サイト オブジェクトを返します。 応答には、サイト作成操作を処理するために作成された getOperationStatus の場所を含む Location ヘッダーも含まれています。 作成操作の状態を確認するには、この場所に対して GET 要求を行います。
例
要求
次の例は要求を示しています。
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;
var requestBody = new Site
{
Name = "Communication Site Test",
WebUrl = "https://contoso.sharepoint.com/sites/commsite1",
Locale = "en-US",
ShareByEmailEnabled = false,
Description = "Test Site Description",
Template = SiteTemplateType.Sitepagepublishing,
OwnerIdentityToResolve = new IdentityInput
{
Email = "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)
locale := "en-US"
requestBody.SetLocale(&locale)
shareByEmailEnabled := false
requestBody.SetShareByEmailEnabled(&shareByEmailEnabled)
description := "Test Site Description"
requestBody.SetDescription(&description)
template := graphmodels.SITEPAGEPUBLISHING_SITETEMPLATETYPE
requestBody.SetTemplate(&template)
ownerIdentityToResolve := graphmodels.NewIdentityInput()
email := "ryan@contoso.com"
ownerIdentityToResolve.SetEmail(&email)
requestBody.SetOwnerIdentityToResolve(ownerIdentityToResolve)
// 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.setLocale("en-US");
site.setShareByEmailEnabled(false);
site.setDescription("Test Site Description");
site.setTemplate(SiteTemplateType.Sitepagepublishing);
IdentityInput ownerIdentityToResolve = new IdentityInput();
ownerIdentityToResolve.setEmail("ryan@contoso.com");
site.setOwnerIdentityToResolve(ownerIdentityToResolve);
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;
use Microsoft\Graph\Beta\Generated\Models\SiteTemplateType;
use Microsoft\Graph\Beta\Generated\Models\IdentityInput;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new Site();
$requestBody->setName('Communication Site Test');
$requestBody->setWebUrl('https://contoso.sharepoint.com/sites/commsite1');
$requestBody->setLocale('en-US');
$requestBody->setShareByEmailEnabled(false);
$requestBody->setDescription('Test Site Description');
$requestBody->setTemplate(new SiteTemplateType('sitepagepublishing'));
$ownerIdentityToResolve = new IdentityInput();
$ownerIdentityToResolve->setEmail('ryan@contoso.com');
$requestBody->setOwnerIdentityToResolve($ownerIdentityToResolve);
$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
from msgraph_beta.generated.models.site_template_type import SiteTemplateType
from msgraph_beta.generated.models.identity_input import IdentityInput
# 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",
locale = "en-US",
share_by_email_enabled = False,
description = "Test Site Description",
template = SiteTemplateType.Sitepagepublishing,
owner_identity_to_resolve = IdentityInput(
email = "ryan@contoso.com",
),
)
result = await graph_client.sites.post(request_body)
応答
次の例は応答を示しています。
HTTP/1.1 202 Accepted
Location: https://graph.microsoft.com/beta/sites/getOperationStatus(operationId='JXMnaHR0cHMlM0ElMkYlMkZncmFwaC5taWNyb3NvZnQuY29tJTJGc2l0ZXMlMkZ0ZWFtc2l0ZTE=')