ユーザーまたはサービス プリンシパルを Microsoft 365 またはセキュリティ グループの所有者に追加します。 所有者は、グループ オブジェクトの変更を許可されている、ユーザーまたはサービス プリンシパルのセットです。
Important: グループの所持者を更新しグループのチームを作成した場合、 Microsoft Teams と所有者が同期するまで最大で 2 時間かかります。 また、たとえば Planner プランを作成することによって所有者が Team で変更を加えられるようにしたい場合は、所有者もグループまたはチームのメンバーとして追加する必要があります。
成功した場合、このメソッドは 204 No Content 応答コードを返します。 応答本文では何も返されません。 このメソッドは、オブジェクトが既にグループのメンバーである場合、 400 Bad Request 応答コードを返します。 このメソッドは、追加されるオブジェクトが存在しない場合、 404 Not Found 応答コードを返します。
POST https://graph.microsoft.com/v1.0/groups/{id}/owners/$ref
Content-type: application/json
{
"@odata.id": "https://graph.microsoft.com/v1.0/users/{id}"
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new ReferenceCreate
{
OdataId = "https://graph.microsoft.com/v1.0/users/{id}",
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
await graphClient.Groups["{group-id}"].Owners.Ref.PostAsync(requestBody);
// THE CLI IS IN PREVIEW. NON-PRODUCTION USE ONLY
mgc groups owners ref post --group-id {group-id} --body '{\
"@odata.id": "https://graph.microsoft.com/v1.0/users/{id}"\
}\
'
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
com.microsoft.graph.models.ReferenceCreate referenceCreate = new com.microsoft.graph.models.ReferenceCreate();
referenceCreate.setOdataId("https://graph.microsoft.com/v1.0/users/{id}");
graphClient.groups().byGroupId("{group-id}").owners().ref().post(referenceCreate);
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Models\ReferenceCreate;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new ReferenceCreate();
$requestBody->setOdataId('https://graph.microsoft.com/v1.0/users/{id}');
$graphServiceClient->groups()->byGroupId('group-id')->owners()->ref()->post($requestBody)->wait();