// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models;
var requestBody = new AppRoleAssignment
{
PrincipalId = Guid.Parse("7679d9a4-2323-44cd-b5c2-673ec88d8b12"),
ResourceId = Guid.Parse("076e8b57-bac8-49d7-9396-e3449b685055"),
AppRoleId = Guid.Parse("00000000-0000-0000-0000-000000000000"),
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Groups["{group-id}"].AppRoleAssignments.PostAsync(requestBody);
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
"github.com/google/uuid"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewAppRoleAssignment()
principalId := uuid.MustParse("7679d9a4-2323-44cd-b5c2-673ec88d8b12")
requestBody.SetPrincipalId(&principalId)
resourceId := uuid.MustParse("076e8b57-bac8-49d7-9396-e3449b685055")
requestBody.SetResourceId(&resourceId)
appRoleId := uuid.MustParse("00000000-0000-0000-0000-000000000000")
requestBody.SetAppRoleId(&appRoleId)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
appRoleAssignments, err := graphClient.Groups().ByGroupId("group-id").AppRoleAssignments().Post(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
AppRoleAssignment appRoleAssignment = new AppRoleAssignment();
appRoleAssignment.setPrincipalId(UUID.fromString("7679d9a4-2323-44cd-b5c2-673ec88d8b12"));
appRoleAssignment.setResourceId(UUID.fromString("076e8b57-bac8-49d7-9396-e3449b685055"));
appRoleAssignment.setAppRoleId(UUID.fromString("00000000-0000-0000-0000-000000000000"));
AppRoleAssignment result = graphClient.groups().byGroupId("{group-id}").appRoleAssignments().post(appRoleAssignment);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Models\AppRoleAssignment;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new AppRoleAssignment();
$requestBody->setPrincipalId('7679d9a4-2323-44cd-b5c2-673ec88d8b12');
$requestBody->setResourceId('076e8b57-bac8-49d7-9396-e3449b685055');
$requestBody->setAppRoleId('00000000-0000-0000-0000-000000000000');
$result = $graphServiceClient->groups()->byGroupId('group-id')->appRoleAssignments()->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.app_role_assignment import AppRoleAssignment
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = AppRoleAssignment(
principal_id = UUID("7679d9a4-2323-44cd-b5c2-673ec88d8b12"),
resource_id = UUID("076e8b57-bac8-49d7-9396-e3449b685055"),
app_role_id = UUID("00000000-0000-0000-0000-000000000000"),
)
result = await graph_client.groups.by_group_id('group-id').app_role_assignments.post(request_body)