Adds specific groups to a lifecycle policy. This action limits the group lifecycle policy to a set of groups only if the managedGroupTypes property of groupLifecyclePolicy is set to Selected.
Choose the permission or permissions marked as least privileged for this API. Use a higher privileged permission or permissions only if your app requires it. For details about delegated and application permissions, see Permission types. To learn more about these permissions, see the permissions reference.
In the request body, provide a JSON object with the following parameters.
Parameter
Type
Description
groupId
String
The identifier of the group to add to the policy.
When the managedGroupTypes property of groupLifecyclePolicy is set to Selected, you can add up to 500 groups to the list. If you need to add more than 500 groups, the managedGroupTypes property of groupLifecyclePolicy must be set to All.
Only one group can be added per request.
Response
If successful, this method returns 200 OK response code. If the group is added to the policy, a true value is returned in the response body. Otherwise, a false value is returned in the response body.
POST https://graph.microsoft.com/v1.0/groupLifecyclePolicies/{id}/addGroup
Content-type: application/json
{
"groupId": "ffffffff-ffff-ffff-ffff-ffffffffffff"
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.GroupLifecyclePolicies.Item.AddGroup;
var requestBody = new AddGroupPostRequestBody
{
GroupId = "ffffffff-ffff-ffff-ffff-ffffffffffff",
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.GroupLifecyclePolicies["{groupLifecyclePolicy-id}"].AddGroup.PostAsAddGroupPostResponseAsync(requestBody);
// 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"
graphgrouplifecyclepolicies "github.com/microsoftgraph/msgraph-sdk-go/grouplifecyclepolicies"
//other-imports
)
requestBody := graphgrouplifecyclepolicies.NewAddGroupPostRequestBody()
groupId := "ffffffff-ffff-ffff-ffff-ffffffffffff"
requestBody.SetGroupId(&groupId)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
addGroup, err := graphClient.GroupLifecyclePolicies().ByGroupLifecyclePolicyId("groupLifecyclePolicy-id").AddGroup().PostAsAddGroupPostResponse(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
com.microsoft.graph.grouplifecyclepolicies.item.addgroup.AddGroupPostRequestBody addGroupPostRequestBody = new com.microsoft.graph.grouplifecyclepolicies.item.addgroup.AddGroupPostRequestBody();
addGroupPostRequestBody.setGroupId("ffffffff-ffff-ffff-ffff-ffffffffffff");
var result = graphClient.groupLifecyclePolicies().byGroupLifecyclePolicyId("{groupLifecyclePolicy-id}").addGroup().post(addGroupPostRequestBody);
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\GroupLifecyclePolicies\Item\AddGroup\AddGroupPostRequestBody;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new AddGroupPostRequestBody();
$requestBody->setGroupId('ffffffff-ffff-ffff-ffff-ffffffffffff');
$result = $graphServiceClient->groupLifecyclePolicies()->byGroupLifecyclePolicyId('groupLifecyclePolicy-id')->addGroup()->post($requestBody)->wait();
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.grouplifecyclepolicies.item.add_group.add_group_post_request_body import AddGroupPostRequestBody
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = AddGroupPostRequestBody(
group_id = "ffffffff-ffff-ffff-ffff-ffffffffffff",
)
result = await graph_client.group_lifecycle_policies.by_group_lifecycle_policy_id('groupLifecyclePolicy-id').add_group.post(request_body)