L’une des autorisations suivantes est nécessaire pour appeler cette API. Pour plus d’informations, notamment sur la façon de choisir les autorisations, voir Autorisations.
Type d’autorisation
Autorisations (de celle qui offre le plus de privilèges à celle qui en offre le moins)
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new DeviceAndAppManagementRoleAssignment
{
OdataType = "#microsoft.graph.deviceAndAppManagementRoleAssignment",
DisplayName = "Display Name value",
Description = "Description value",
ResourceScopes = new List<string>
{
"Resource Scopes value",
},
Members = new List<string>
{
"Members value",
},
};
// To initialize your graphClient, see https://zcusa.951200.xyz/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.DeviceManagement.RoleAssignments.PostAsync(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"
graphmodels "github.com/microsoftgraph/msgraph-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewDeviceAndAppManagementRoleAssignment()
displayName := "Display Name value"
requestBody.SetDisplayName(&displayName)
description := "Description value"
requestBody.SetDescription(&description)
resourceScopes := []string {
"Resource Scopes value",
}
requestBody.SetResourceScopes(resourceScopes)
members := []string {
"Members value",
}
requestBody.SetMembers(members)
// To initialize your graphClient, see https://zcusa.951200.xyz/en-us/graph/sdks/create-client?from=snippets&tabs=go
roleAssignments, err := graphClient.DeviceManagement().RoleAssignments().Post(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
DeviceAndAppManagementRoleAssignment deviceAndAppManagementRoleAssignment = new DeviceAndAppManagementRoleAssignment();
deviceAndAppManagementRoleAssignment.setOdataType("#microsoft.graph.deviceAndAppManagementRoleAssignment");
deviceAndAppManagementRoleAssignment.setDisplayName("Display Name value");
deviceAndAppManagementRoleAssignment.setDescription("Description value");
LinkedList<String> resourceScopes = new LinkedList<String>();
resourceScopes.add("Resource Scopes value");
deviceAndAppManagementRoleAssignment.setResourceScopes(resourceScopes);
LinkedList<String> members = new LinkedList<String>();
members.add("Members value");
deviceAndAppManagementRoleAssignment.setMembers(members);
DeviceAndAppManagementRoleAssignment result = graphClient.deviceManagement().roleAssignments().post(deviceAndAppManagementRoleAssignment);
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.models.device_and_app_management_role_assignment import DeviceAndAppManagementRoleAssignment
# To initialize your graph_client, see https://zcusa.951200.xyz/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = DeviceAndAppManagementRoleAssignment(
odata_type = "#microsoft.graph.deviceAndAppManagementRoleAssignment",
display_name = "Display Name value",
description = "Description value",
resource_scopes = [
"Resource Scopes value",
],
members = [
"Members value",
],
)
result = await graph_client.device_management.role_assignments.post(request_body)
Voici un exemple de réponse. Remarque : l’objet de réponse illustré ici peut être tronqué à des fins de concision. Toutes les propriétés sont renvoyées à partir d’un appel réel.