Upsert グループ
[アーティクル]
04/21/2024
5 人の共同作成者
フィードバック
この記事の内容
名前空間: microsoft.graph
新しい グループ オブジェクトが存在しない場合は作成するか、既存の グループ オブジェクトのプロパティを更新します。
次の種類のグループを作成または更新できます。
Microsoft 365 グループ (統合グループ)
セキュリティ グループ
既定では、この操作は各グループのプロパティのサブセットのみを返します。 既定で返されるプロパティの一覧については、グループ リソースの [プロパティ ] セクションを参照してください。 既定で返されない プロパティを取得するには、GET 操作 を実行し、$select
OData クエリ オプションでプロパティを指定します。
注 : チーム を作成するには、まずグループを作成してから、チームを追加します。 詳細については、「チームの 作成 」を参照してください。
アクセス許可
この API の最小特権としてマークされているアクセス許可またはアクセス許可を選択します。
アプリで必要な場合にのみ 、より高い特権のアクセス許可またはアクセス許可を使用します。 委任されたアクセス許可とアプリケーションのアクセス許可の詳細については、「アクセス許可の種類 」を参照してください。 これらのアクセス許可の詳細については、「アクセス許可のリファレンス 」を参照してください。
アクセス許可の種類
最小特権アクセス許可
より高い特権のアクセス許可
委任 (職場または学校のアカウント)
Group.ReadWrite.All
Directory.ReadWrite.All
委任 (個人用 Microsoft アカウント)
サポートされていません。
サポートされていません。
アプリケーション
Group.Create
Directory.ReadWrite.All、Group.ReadWrite.All
Group.Create アクセス許可を持つアプリが所有者またはメンバーを持つグループを作成するには、グループ所有者またはメンバーとして割り当てるオブジェクトの種類を読み取る権限が必要です。 そこで:
アプリは、グループの所有者またはメンバーとして自身を割り当てることができます。
所有者またはメンバーとしてユーザーを含むグループを作成するには、アプリに少なくとも User.Read.All アクセス許可が必要です。
所有者またはメンバーとして他のサービス プリンシパルを使用してグループを作成するには、アプリに 少なくとも Application.Read.All アクセス許可が必要です。
ユーザーまたはサービス プリンシパルを所有者またはメンバーとしてグループを作成するには、アプリに少なくとも Directory.Read.All アクセス許可が必要です。
HTTP 要求
PATCH /groups/(uniqueName='uniqueName')
名前
説明
Authorization
ベアラー {token}。 必須です。
認証と認可 についての詳細をご覧ください。
Content-Type
application/json. Required.
Prefer
create-if-missing
. アップサート動作に必要です。それ以外の場合、要求は更新操作として扱われます。
要求本文
要求本文で、グループ オブジェクトの JSON 表記を指定します。
次の表に、 グループ を作成するときに必要なプロパティを示します。 作成または更新時にグループに必要に応じて、他の書き込み可能なプロパティを指定します。
プロパティ
種類
説明
displayName
String
アドレス帳に表示するグループの名前。 最大文字数は 256 文字です。 必須です。
mailEnabled
Boolean
メールが有効なグループの場合は、true
に設定します。 必須です。
mailNickname
String
組織内の Microsoft 365 グループに対して一意の、グループのメール エイリアス。 最大文字数は 64 文字です。 このプロパティには、 ASCII 文字セット 0 ~ 127 の文字のみを含めることができます。ただし、以下の @ () \ [] " ; : <> , SPACE
を除いたものです。 必須です。
securityEnabled
Boolean
Microsoft 365 グループを含む、セキュリティが有効なグループに true
を設定します。 必須です。
手記: Microsoft Entra 管理センターまたは Azure portal を使用して作成されたグループには、常に securityEnabled が最初に true
に設定されています。
重要
Group.Create アプリケーションのアクセス許可を使用して所有者を指定せずにグループを作成すると、グループが匿名で作成され、そのグループは変更できなくなります。 グループを変更できる所有者を指定するには、グループの作成中に所有者をグループに追加します。
所有者を指定しないで、アプリ専用コンテキストを用いたプログラムに従って Microsoft 365 グループを作成すると、グループは匿名で作成されます。 この操作を行うと、さらに手動操作が行われるまで、関連付けられている SharePoint Online サイトが自動的に作成されない可能性があります。
最初の POST 要求では次のプロパティを設定できないため、後続の PATCH 要求で設定する必要があります。 allowExternalSenders 、 autoSubscribeNewMembers 、 hideFromAddressLists 、 hideFromOutlookClients 、 isSubscribedByMail 、 unseenCount 。
グループ リソースは拡張機能 をサポートしているため、 リソースの作成時にカスタム プロパティを独自のデータとともにグループに追加することができます。
groupTypes オプション
示すように、groupTypes プロパティを使用し、グループの種類とグループのメンバーシップを管理します:
グループの種類
割り当て済みのメンバーシップ
動的メンバーシップ
Microsoft 365 (統合グループ)
["Unified"]
["Unified","DynamicMembership"]
Dynamic
[]
(null )
["DynamicMembership"]
応答
成功した場合、 uniqueName を持つオブジェクトが存在しない場合、このメソッドは応答コード 201 Created
と、応答本文に新しい グループ オブジェクトを返します。
uniqueName を持つオブジェクトが既に存在する場合、このメソッドはグループ オブジェクトを更新し、204 No Content
応答コードを返します。
例
例 1: Microsoft 365 グループが存在しない場合は作成する
次の例では、 指定された uniqueName 値を持つグループが存在しないため、Microsoft 365 グループを作成します。 所有者が指定されていないため、呼び出し元ユーザーはグループの所有者として自動的に追加されます。
要求
PATCH https://graph.microsoft.com/v1.0/groups(uniqueName='uniqueName')
Content-type: application/json
Prefer: create-if-missing
{
"description": "Self help community for golf",
"displayName": "Golf Assist",
"groupTypes": [
"Unified"
],
"mailEnabled": true,
"mailNickname": "golfassist",
"securityEnabled": false
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new Group
{
Description = "Self help community for golf",
DisplayName = "Golf Assist",
GroupTypes = new List<string>
{
"Unified",
},
MailEnabled = true,
MailNickname = "golfassist",
SecurityEnabled = false,
};
// To initialize your graphClient, see https://video2.skills-academy.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.GroupsWithUniqueName("{uniqueName}").PatchAsync(requestBody, (requestConfiguration) =>
{
requestConfiguration.Headers.Add("Prefer", "create-if-missing");
});
プロジェクトに SDK を追加 し、authProvider インスタンスを作成 する方法の詳細については、SDK のドキュメント を参照してください。
mgc groups-with-unique-name patch --unique-name {unique-name-id} --body '{\
"description": "Self help community for golf",\
"displayName": "Golf Assist",\
"groupTypes": [\
"Unified"\
],\
"mailEnabled": true,\
"mailNickname": "golfassist",\
"securityEnabled": false\
}\
'
プロジェクトに SDK を追加 し、authProvider インスタンスを作成 する方法の詳細については、SDK のドキュメント を参照してください。
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
abstractions "github.com/microsoft/kiota-abstractions-go"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-sdk-go/models"
graphgroupswithuniquename "github.com/microsoftgraph/msgraph-sdk-go/groupswithuniquename"
//other-imports
)
headers := abstractions.NewRequestHeaders()
headers.Add("Prefer", "create-if-missing")
configuration := &graphgroupswithuniquename.GroupsWithUniqueNameRequestBuilderPatchRequestConfiguration{
Headers: headers,
}
requestBody := graphmodels.NewGroup()
description := "Self help community for golf"
requestBody.SetDescription(&description)
displayName := "Golf Assist"
requestBody.SetDisplayName(&displayName)
groupTypes := []string {
"Unified",
}
requestBody.SetGroupTypes(groupTypes)
mailEnabled := true
requestBody.SetMailEnabled(&mailEnabled)
mailNickname := "golfassist"
requestBody.SetMailNickname(&mailNickname)
securityEnabled := false
requestBody.SetSecurityEnabled(&securityEnabled)
// To initialize your graphClient, see https://video2.skills-academy.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
uniqueName := "{uniqueName}"
groups, err := graphClient.GroupsWithUniqueName(&uniqueName).Patch(context.Background(), requestBody, configuration)
プロジェクトに SDK を追加 し、authProvider インスタンスを作成 する方法の詳細については、SDK のドキュメント を参照してください。
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
Group group = new Group();
group.setDescription("Self help community for golf");
group.setDisplayName("Golf Assist");
LinkedList<String> groupTypes = new LinkedList<String>();
groupTypes.add("Unified");
group.setGroupTypes(groupTypes);
group.setMailEnabled(true);
group.setMailNickname("golfassist");
group.setSecurityEnabled(false);
Group result = graphClient.groupsWithUniqueName("{uniqueName}").patch(group, requestConfiguration -> {
requestConfiguration.headers.add("Prefer", "create-if-missing");
});
プロジェクトに SDK を追加 し、authProvider インスタンスを作成 する方法の詳細については、SDK のドキュメント を参照してください。
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Groups(uniqueName='{uniqueName}')\GroupsWithUniqueNameRequestBuilderPatchRequestConfiguration;
use Microsoft\Graph\Generated\Models\Group;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new Group();
$requestBody->setDescription('Self help community for golf');
$requestBody->setDisplayName('Golf Assist');
$requestBody->setGroupTypes(['Unified', ]);
$requestBody->setMailEnabled(true);
$requestBody->setMailNickname('golfassist');
$requestBody->setSecurityEnabled(false);
$requestConfiguration = new GroupsWithUniqueNameRequestBuilderPatchRequestConfiguration();
$headers = [
'Prefer' => 'create-if-missing',
];
$requestConfiguration->headers = $headers;
$result = $graphServiceClient->groupsWithUniqueName('{uniqueName}', )->patch($requestBody, $requestConfiguration)->wait();
プロジェクトに SDK を追加 し、authProvider インスタンスを作成 する方法の詳細については、SDK のドキュメント を参照してください。
Import-Module Microsoft.Graph.Groups
$params = @{
description = "Self help community for golf"
displayName = "Golf Assist"
groupTypes = @(
"Unified"
)
mailEnabled = $true
mailNickname = "golfassist"
securityEnabled = $false
}
Update-MgGroupByUniqueName -BodyParameter $params -UniqueName $uniqueNameId
プロジェクトに SDK を追加 し、authProvider インスタンスを作成 する方法の詳細については、SDK のドキュメント を参照してください。
from msgraph import GraphServiceClient
from msgraph.generated.groups(unique_name='{unique_name}').groups_with_unique_name_request_builder import GroupsWithUniqueNameRequestBuilder
from kiota_abstractions.base_request_configuration import RequestConfiguration
from msgraph.generated.models.group import Group
graph_client = GraphServiceClient(credentials, scopes)
request_body = Group(
description = "Self help community for golf",
display_name = "Golf Assist",
group_types = [
"Unified",
],
mail_enabled = True,
mail_nickname = "golfassist",
security_enabled = False,
)
request_configuration = RequestConfiguration()
request_configuration.headers.add("Prefer", "create-if-missing")
result = await graph_client.groups_with_unique_name("{uniqueName}").patch(request_body, request_configuration = request_configuration)
プロジェクトに SDK を追加 し、authProvider インスタンスを作成 する方法の詳細については、SDK のドキュメント を参照してください。
応答
次の例は応答を示しています。
preferredDataLocation プロパティの値は、グループ作成者の優先されるデータの場所から継承されます。
注: ここに示す応答オブジェクトは、読みやすさのために短縮されている場合があります。
HTTP/1.1 201 Created
Content-type: application/json
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#groups/$entity",
"id": "45b7d2e7-b882-4a80-ba97-10b7a63b8fa4",
"deletedDateTime": null,
"classification": null,
"createdDateTime": "2018-12-22T02:21:05Z",
"description": "Self help community for golf",
"displayName": "Golf Assist",
"expirationDateTime": null,
"groupTypes": [
"Unified"
],
"isAssignableToRole": null,
"mail": "golfassist@contoso.com",
"mailEnabled": true,
"mailNickname": "golfassist",
"membershipRule": null,
"membershipRuleProcessingState": null,
"onPremisesLastSyncDateTime": null,
"onPremisesSecurityIdentifier": null,
"onPremisesSyncEnabled": null,
"preferredDataLocation": "CAN",
"preferredLanguage": null,
"proxyAddresses": [
"SMTP:golfassist@contoso.onmicrosoft.com"
],
"renewedDateTime": "2018-12-22T02:21:05Z",
"resourceBehaviorOptions": [],
"resourceProvisioningOptions": [],
"securityEnabled": false,
"securityIdentifier": "S-1-12-1-1753967289-1089268234-832641959-555555555",
"theme": null,
"visibility": "Public",
"uniqueName": "uniqueName",
"onPremisesProvisioningErrors": []
}
例 2: 所有者とメンバーが存在しない場合は、セキュリティ グループを作成する
次の例では、 指定された uniqueName 値を持つグループが存在しないため、所有者とメンバーが指定されたセキュリティ グループを作成します。 グループ作成の一部として、所有者やメンバーなどの最大 20 個の関係を追加できます。 その後、メンバーの追加 API または JSON バッチ処理を使用して、複数の 追加メンバーを追加 できます。
要求
次の例は要求を示しています。
PATCH https://graph.microsoft.com/v1.0/groups(uniqueName='uniqueName')
Content-Type: application/json
{
"description": "Group with designated owner and members",
"displayName": "Operations group",
"groupTypes": [
],
"mailEnabled": false,
"mailNickname": "operations2019",
"securityEnabled": true,
"owners@odata.bind": [
"https://graph.microsoft.com/v1.0/users/26be1845-4119-4801-a799-aea79d09f1a2"
],
"members@odata.bind": [
"https://graph.microsoft.com/v1.0/users/ff7cb387-6688-423c-8188-3da9532a73cc",
"https://graph.microsoft.com/v1.0/users/69456242-0067-49d3-ba96-9de6f2728e14"
]
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new Group
{
Description = "Group with designated owner and members",
DisplayName = "Operations group",
GroupTypes = new List<string>
{
},
MailEnabled = false,
MailNickname = "operations2019",
SecurityEnabled = true,
AdditionalData = new Dictionary<string, object>
{
{
"owners@odata.bind" , new List<string>
{
"https://graph.microsoft.com/v1.0/users/26be1845-4119-4801-a799-aea79d09f1a2",
}
},
{
"members@odata.bind" , new List<string>
{
"https://graph.microsoft.com/v1.0/users/ff7cb387-6688-423c-8188-3da9532a73cc",
"https://graph.microsoft.com/v1.0/users/69456242-0067-49d3-ba96-9de6f2728e14",
}
},
},
};
// To initialize your graphClient, see https://video2.skills-academy.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.GroupsWithUniqueName("{uniqueName}").PatchAsync(requestBody);
プロジェクトに SDK を追加 し、authProvider インスタンスを作成 する方法の詳細については、SDK のドキュメント を参照してください。
mgc groups-with-unique-name patch --unique-name {unique-name-id} --body '{\
"description": "Group with designated owner and members",\
"displayName": "Operations group",\
"groupTypes": [\
],\
"mailEnabled": false,\
"mailNickname": "operations2019",\
"securityEnabled": true,\
"owners@odata.bind": [\
"https://graph.microsoft.com/v1.0/users/26be1845-4119-4801-a799-aea79d09f1a2"\
],\
"members@odata.bind": [\
"https://graph.microsoft.com/v1.0/users/ff7cb387-6688-423c-8188-3da9532a73cc",\
"https://graph.microsoft.com/v1.0/users/69456242-0067-49d3-ba96-9de6f2728e14"\
]\
}\
'
プロジェクトに SDK を追加 し、authProvider インスタンスを作成 する方法の詳細については、SDK のドキュメント を参照してください。
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewGroup()
description := "Group with designated owner and members"
requestBody.SetDescription(&description)
displayName := "Operations group"
requestBody.SetDisplayName(&displayName)
groupTypes := []string {
}
requestBody.SetGroupTypes(groupTypes)
mailEnabled := false
requestBody.SetMailEnabled(&mailEnabled)
mailNickname := "operations2019"
requestBody.SetMailNickname(&mailNickname)
securityEnabled := true
requestBody.SetSecurityEnabled(&securityEnabled)
additionalData := map[string]interface{}{
odataBind := []string {
"https://graph.microsoft.com/v1.0/users/26be1845-4119-4801-a799-aea79d09f1a2",
}
odataBind := []string {
"https://graph.microsoft.com/v1.0/users/ff7cb387-6688-423c-8188-3da9532a73cc",
"https://graph.microsoft.com/v1.0/users/69456242-0067-49d3-ba96-9de6f2728e14",
}
}
requestBody.SetAdditionalData(additionalData)
// To initialize your graphClient, see https://video2.skills-academy.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
uniqueName := "{uniqueName}"
groups, err := graphClient.GroupsWithUniqueName(&uniqueName).Patch(context.Background(), requestBody, nil)
プロジェクトに SDK を追加 し、authProvider インスタンスを作成 する方法の詳細については、SDK のドキュメント を参照してください。
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
Group group = new Group();
group.setDescription("Group with designated owner and members");
group.setDisplayName("Operations group");
LinkedList<String> groupTypes = new LinkedList<String>();
group.setGroupTypes(groupTypes);
group.setMailEnabled(false);
group.setMailNickname("operations2019");
group.setSecurityEnabled(true);
HashMap<String, Object> additionalData = new HashMap<String, Object>();
LinkedList<String> ownersOdataBind = new LinkedList<String>();
ownersOdataBind.add("https://graph.microsoft.com/v1.0/users/26be1845-4119-4801-a799-aea79d09f1a2");
additionalData.put("owners@odata.bind", ownersOdataBind);
LinkedList<String> membersOdataBind = new LinkedList<String>();
membersOdataBind.add("https://graph.microsoft.com/v1.0/users/ff7cb387-6688-423c-8188-3da9532a73cc");
membersOdataBind.add("https://graph.microsoft.com/v1.0/users/69456242-0067-49d3-ba96-9de6f2728e14");
additionalData.put("members@odata.bind", membersOdataBind);
group.setAdditionalData(additionalData);
Group result = graphClient.groupsWithUniqueName("{uniqueName}").patch(group);
プロジェクトに SDK を追加 し、authProvider インスタンスを作成 する方法の詳細については、SDK のドキュメント を参照してください。
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Models\Group;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new Group();
$requestBody->setDescription('Group with designated owner and members');
$requestBody->setDisplayName('Operations group');
$requestBody->setGroupTypes([ ]);
$requestBody->setMailEnabled(false);
$requestBody->setMailNickname('operations2019');
$requestBody->setSecurityEnabled(true);
$additionalData = [
'owners@odata.bind' => [
'https://graph.microsoft.com/v1.0/users/26be1845-4119-4801-a799-aea79d09f1a2', ],
'members@odata.bind' => [
'https://graph.microsoft.com/v1.0/users/ff7cb387-6688-423c-8188-3da9532a73cc', 'https://graph.microsoft.com/v1.0/users/69456242-0067-49d3-ba96-9de6f2728e14', ],
];
$requestBody->setAdditionalData($additionalData);
$result = $graphServiceClient->groupsWithUniqueName('{uniqueName}', )->patch($requestBody)->wait();
プロジェクトに SDK を追加 し、authProvider インスタンスを作成 する方法の詳細については、SDK のドキュメント を参照してください。
Import-Module Microsoft.Graph.Groups
$params = @{
description = "Group with designated owner and members"
displayName = "Operations group"
groupTypes = @(
)
mailEnabled = $false
mailNickname = "operations2019"
securityEnabled = $true
"owners@odata.bind" = @(
"https://graph.microsoft.com/v1.0/users/26be1845-4119-4801-a799-aea79d09f1a2"
)
"members@odata.bind" = @(
"https://graph.microsoft.com/v1.0/users/ff7cb387-6688-423c-8188-3da9532a73cc"
"https://graph.microsoft.com/v1.0/users/69456242-0067-49d3-ba96-9de6f2728e14"
)
}
Update-MgGroupByUniqueName -BodyParameter $params -UniqueName $uniqueNameId
プロジェクトに SDK を追加 し、authProvider インスタンスを作成 する方法の詳細については、SDK のドキュメント を参照してください。
from msgraph import GraphServiceClient
from msgraph.generated.models.group import Group
graph_client = GraphServiceClient(credentials, scopes)
request_body = Group(
description = "Group with designated owner and members",
display_name = "Operations group",
group_types = [
],
mail_enabled = False,
mail_nickname = "operations2019",
security_enabled = True,
additional_data = {
"owners@odata_bind" : [
"https://graph.microsoft.com/v1.0/users/26be1845-4119-4801-a799-aea79d09f1a2",
],
"members@odata_bind" : [
"https://graph.microsoft.com/v1.0/users/ff7cb387-6688-423c-8188-3da9532a73cc",
"https://graph.microsoft.com/v1.0/users/69456242-0067-49d3-ba96-9de6f2728e14",
],
}
)
result = await graph_client.groups_with_unique_name("{uniqueName}").patch(request_body)
プロジェクトに SDK を追加 し、authProvider インスタンスを作成 する方法の詳細については、SDK のドキュメント を参照してください。
応答
成功応答の例を次に示します。 既定のプロパティのみが含まれています。 その後は、グループの owners ナビゲーション プロパティまたは members ナビゲーション プロパティを取得して所有者またはメンバーの詳細を確認できます。
preferredDataLocation プロパティの値は、グループ作成者の優先されるデータの場所から継承されます。
注: ここに示す応答オブジェクトは、読みやすさのために短縮されている場合があります。
HTTP/1.1 201 Created
Content-type: application/json
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#groups/$entity",
"@odata.id": "https://graph.microsoft.com/v2/84841066-274d-4ec0-a5c1-276be684bdd3/directoryObjects/1226170d-83d5-49b8-99ab-d1ab3d91333e/Microsoft.DirectoryServices.Group",
"id": "1226170d-83d5-49b8-99ab-d1ab3d91333e",
"deletedDateTime": null,
"classification": null,
"createdDateTime": "2021-09-21T07:14:44Z",
"createdByAppId": "de8bc8b5-d9f9-48b1-a8ad-b748da725064",
"organizationId": "84841066-274d-4ec0-a5c1-276be684bdd3",
"description": "Group with designated owner and members",
"displayName": "Operations group",
"expirationDateTime": null,
"groupTypes": [],
"infoCatalogs": [],
"isAssignableToRole": null,
"isManagementRestricted": null,
"mail": null,
"mailEnabled": false,
"mailNickname": "operations2019",
"membershipRule": null,
"membershipRuleProcessingState": null,
"onPremisesDomainName": null,
"onPremisesLastSyncDateTime": null,
"onPremisesNetBiosName": null,
"onPremisesSamAccountName": null,
"onPremisesSecurityIdentifier": null,
"onPremisesSyncEnabled": null,
"preferredDataLocation": null,
"preferredLanguage": null,
"proxyAddresses": [],
"renewedDateTime": "2021-09-21T07:14:44Z",
"resourceBehaviorOptions": [],
"resourceProvisioningOptions": [],
"securityEnabled": true,
"securityIdentifier": "S-1-12-1-304486157-1236829141-2882644889-1043566909",
"theme": null,
"uniqueName": "uniqueName",
"visibility": null,
"writebackConfiguration": {
"isEnabled": null,
"onPremisesGroupType": null
},
"onPremisesProvisioningErrors": []
}
例 3: 既存のグループを更新する
この例では、指定したグループが既に存在するため、操作は更新プログラムとして扱われます。
要求
次の例は要求を示しています。
POST https://graph.microsoft.com/v1.0/groups
Content-Type: application/json
{
"description": "Group assignable to a role",
"displayName": "Role assignable group",
"groupTypes": [
"Unified"
],
"isAssignableToRole": true,
"mailEnabled": true,
"securityEnabled": true,
"mailNickname": "contosohelpdeskadministrators",
"owners@odata.bind": [
"https://graph.microsoft.com/v1.0/users/99e44b05-c10b-4e95-a523-e2732bbaba1e"
],
"members@odata.bind": [
"https://graph.microsoft.com/v1.0/users/6ea91a8d-e32e-41a1-b7bd-d2d185eed0e0",
"https://graph.microsoft.com/v1.0/users/4562bcc8-c436-4f95-b7c0-4f8ce89dca5e"
]
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new Group
{
Description = "Group assignable to a role",
DisplayName = "Role assignable group",
GroupTypes = new List<string>
{
"Unified",
},
IsAssignableToRole = true,
MailEnabled = true,
SecurityEnabled = true,
MailNickname = "contosohelpdeskadministrators",
AdditionalData = new Dictionary<string, object>
{
{
"owners@odata.bind" , new List<string>
{
"https://graph.microsoft.com/v1.0/users/99e44b05-c10b-4e95-a523-e2732bbaba1e",
}
},
{
"members@odata.bind" , new List<string>
{
"https://graph.microsoft.com/v1.0/users/6ea91a8d-e32e-41a1-b7bd-d2d185eed0e0",
"https://graph.microsoft.com/v1.0/users/4562bcc8-c436-4f95-b7c0-4f8ce89dca5e",
}
},
},
};
// To initialize your graphClient, see https://video2.skills-academy.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Groups.PostAsync(requestBody);
プロジェクトに SDK を追加 し、authProvider インスタンスを作成 する方法の詳細については、SDK のドキュメント を参照してください。
mgc groups create --body '{\
"description": "Group assignable to a role",\
"displayName": "Role assignable group",\
"groupTypes": [\
"Unified"\
],\
"isAssignableToRole": true,\
"mailEnabled": true,\
"securityEnabled": true,\
"mailNickname": "contosohelpdeskadministrators",\
"owners@odata.bind": [\
"https://graph.microsoft.com/v1.0/users/99e44b05-c10b-4e95-a523-e2732bbaba1e"\
],\
"members@odata.bind": [\
"https://graph.microsoft.com/v1.0/users/6ea91a8d-e32e-41a1-b7bd-d2d185eed0e0",\
"https://graph.microsoft.com/v1.0/users/4562bcc8-c436-4f95-b7c0-4f8ce89dca5e"\
]\
}\
'
プロジェクトに SDK を追加 し、authProvider インスタンスを作成 する方法の詳細については、SDK のドキュメント を参照してください。
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewGroup()
description := "Group assignable to a role"
requestBody.SetDescription(&description)
displayName := "Role assignable group"
requestBody.SetDisplayName(&displayName)
groupTypes := []string {
"Unified",
}
requestBody.SetGroupTypes(groupTypes)
isAssignableToRole := true
requestBody.SetIsAssignableToRole(&isAssignableToRole)
mailEnabled := true
requestBody.SetMailEnabled(&mailEnabled)
securityEnabled := true
requestBody.SetSecurityEnabled(&securityEnabled)
mailNickname := "contosohelpdeskadministrators"
requestBody.SetMailNickname(&mailNickname)
additionalData := map[string]interface{}{
odataBind := []string {
"https://graph.microsoft.com/v1.0/users/99e44b05-c10b-4e95-a523-e2732bbaba1e",
}
odataBind := []string {
"https://graph.microsoft.com/v1.0/users/6ea91a8d-e32e-41a1-b7bd-d2d185eed0e0",
"https://graph.microsoft.com/v1.0/users/4562bcc8-c436-4f95-b7c0-4f8ce89dca5e",
}
}
requestBody.SetAdditionalData(additionalData)
// To initialize your graphClient, see https://video2.skills-academy.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
groups, err := graphClient.Groups().Post(context.Background(), requestBody, nil)
プロジェクトに SDK を追加 し、authProvider インスタンスを作成 する方法の詳細については、SDK のドキュメント を参照してください。
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
Group group = new Group();
group.setDescription("Group assignable to a role");
group.setDisplayName("Role assignable group");
LinkedList<String> groupTypes = new LinkedList<String>();
groupTypes.add("Unified");
group.setGroupTypes(groupTypes);
group.setIsAssignableToRole(true);
group.setMailEnabled(true);
group.setSecurityEnabled(true);
group.setMailNickname("contosohelpdeskadministrators");
HashMap<String, Object> additionalData = new HashMap<String, Object>();
LinkedList<String> ownersOdataBind = new LinkedList<String>();
ownersOdataBind.add("https://graph.microsoft.com/v1.0/users/99e44b05-c10b-4e95-a523-e2732bbaba1e");
additionalData.put("owners@odata.bind", ownersOdataBind);
LinkedList<String> membersOdataBind = new LinkedList<String>();
membersOdataBind.add("https://graph.microsoft.com/v1.0/users/6ea91a8d-e32e-41a1-b7bd-d2d185eed0e0");
membersOdataBind.add("https://graph.microsoft.com/v1.0/users/4562bcc8-c436-4f95-b7c0-4f8ce89dca5e");
additionalData.put("members@odata.bind", membersOdataBind);
group.setAdditionalData(additionalData);
Group result = graphClient.groups().post(group);
プロジェクトに SDK を追加 し、authProvider インスタンスを作成 する方法の詳細については、SDK のドキュメント を参照してください。
const options = {
authProvider,
};
const client = Client.init(options);
const group = {
description: 'Group assignable to a role',
displayName: 'Role assignable group',
groupTypes: [
'Unified'
],
isAssignableToRole: true,
mailEnabled: true,
securityEnabled: true,
mailNickname: 'contosohelpdeskadministrators',
'owners@odata.bind': [
'https://graph.microsoft.com/v1.0/users/99e44b05-c10b-4e95-a523-e2732bbaba1e'
],
'members@odata.bind': [
'https://graph.microsoft.com/v1.0/users/6ea91a8d-e32e-41a1-b7bd-d2d185eed0e0',
'https://graph.microsoft.com/v1.0/users/4562bcc8-c436-4f95-b7c0-4f8ce89dca5e'
]
};
await client.api('/groups')
.post(group);
プロジェクトに SDK を追加 し、authProvider インスタンスを作成 する方法の詳細については、SDK のドキュメント を参照してください。
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Models\Group;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new Group();
$requestBody->setDescription('Group assignable to a role');
$requestBody->setDisplayName('Role assignable group');
$requestBody->setGroupTypes(['Unified', ]);
$requestBody->setIsAssignableToRole(true);
$requestBody->setMailEnabled(true);
$requestBody->setSecurityEnabled(true);
$requestBody->setMailNickname('contosohelpdeskadministrators');
$additionalData = [
'owners@odata.bind' => [
'https://graph.microsoft.com/v1.0/users/99e44b05-c10b-4e95-a523-e2732bbaba1e', ],
'members@odata.bind' => [
'https://graph.microsoft.com/v1.0/users/6ea91a8d-e32e-41a1-b7bd-d2d185eed0e0', 'https://graph.microsoft.com/v1.0/users/4562bcc8-c436-4f95-b7c0-4f8ce89dca5e', ],
];
$requestBody->setAdditionalData($additionalData);
$result = $graphServiceClient->groups()->post($requestBody)->wait();
プロジェクトに SDK を追加 し、authProvider インスタンスを作成 する方法の詳細については、SDK のドキュメント を参照してください。
Import-Module Microsoft.Graph.Groups
$params = @{
description = "Group assignable to a role"
displayName = "Role assignable group"
groupTypes = @(
"Unified"
)
isAssignableToRole = $true
mailEnabled = $true
securityEnabled = $true
mailNickname = "contosohelpdeskadministrators"
"owners@odata.bind" = @(
"https://graph.microsoft.com/v1.0/users/99e44b05-c10b-4e95-a523-e2732bbaba1e"
)
"members@odata.bind" = @(
"https://graph.microsoft.com/v1.0/users/6ea91a8d-e32e-41a1-b7bd-d2d185eed0e0"
"https://graph.microsoft.com/v1.0/users/4562bcc8-c436-4f95-b7c0-4f8ce89dca5e"
)
}
New-MgGroup -BodyParameter $params
プロジェクトに SDK を追加 し、authProvider インスタンスを作成 する方法の詳細については、SDK のドキュメント を参照してください。
from msgraph import GraphServiceClient
from msgraph.generated.models.group import Group
graph_client = GraphServiceClient(credentials, scopes)
request_body = Group(
description = "Group assignable to a role",
display_name = "Role assignable group",
group_types = [
"Unified",
],
is_assignable_to_role = True,
mail_enabled = True,
security_enabled = True,
mail_nickname = "contosohelpdeskadministrators",
additional_data = {
"owners@odata_bind" : [
"https://graph.microsoft.com/v1.0/users/99e44b05-c10b-4e95-a523-e2732bbaba1e",
],
"members@odata_bind" : [
"https://graph.microsoft.com/v1.0/users/6ea91a8d-e32e-41a1-b7bd-d2d185eed0e0",
"https://graph.microsoft.com/v1.0/users/4562bcc8-c436-4f95-b7c0-4f8ce89dca5e",
],
}
)
result = await graph_client.groups.post(request_body)
プロジェクトに SDK を追加 し、authProvider インスタンスを作成 する方法の詳細については、SDK のドキュメント を参照してください。
応答
次の例は応答を示しています。
preferredDataLocation プロパティの値は、グループ作成者の優先されるデータの場所から継承されます。
HTTP/1.1 204 No Content
関連コンテンツ