Namespace: microsoft.graph
Important
APIs under the /beta
version in Microsoft Graph are subject to change. Use of these APIs in production applications is not supported. To determine whether an API is available in v1.0, use the Version selector.
Create a new unifiedRoleAssignmentScheduleRequest object. This operation allows both admins and users to add, remove, extend, or renew assignments. To run this request, the calling user must have multifactor authentication (MFA) enforced, and running the query in a session in which they were challenged for MFA. See Enable per-user Microsoft Entra multifactor authentication to secure sign-in events.
This API is available in the following national cloud deployments.
Global service |
US Government L4 |
US Government L5 (DOD) |
China operated by 21Vianet |
✅ |
✅ |
✅ |
✅ |
Permissions
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.
Permission type |
Least privileged permissions |
Higher privileged permissions |
Delegated (work or school account) |
RoleAssignmentSchedule.ReadWrite.Directory |
RoleAssignmentSchedule.Remove.Directory, RoleEligibilitySchedule.Remove.Directory, RoleManagement.ReadWrite.Directory |
Delegated (personal Microsoft account) |
Not supported. |
Not supported. |
Application |
RoleAssignmentSchedule.ReadWrite.Directory |
RoleManagement.ReadWrite.Directory, RoleAssignmentSchedule.Remove.Directory, RoleEligibilitySchedule.Remove.Directory |
Important
In delegated scenarios with work or school accounts, the signed-in user must be assigned a supported Microsoft Entra role or a custom role with a supported role permission. The following least privileged roles are supported for this operation.
- For read operations: Global Reader, Security Operator, Security Reader, Security Administrator, or Privileged Role Administrator
- For write operations: Privileged Role Administrator
HTTP request
POST /roleManagement/directory/roleAssignmentScheduleRequests
Request body
In the request body, supply a JSON representation of the unifiedRoleAssignmentScheduleRequest object.
The following table lists the properties that are required when you create the unifiedRoleAssignmentScheduleRequest.
Property |
Type |
Description |
id |
String |
The unique identifier for the unifiedRoleAssignmentScheduleRequest. Key, not nullable, Read-only. |
action |
String |
Represents the type of the operation on the role assignment. The possible values are: AdminAssign : For administrators to assign roles to users or groups.AdminRemove : For administrators to remove users or groups from roles.-
AdminUpdate : For administrators to change existing role assignments. AdminExtend : For administrators to extend expiring assignments.AdminRenew : For administrators to renew expired assignments.SelfActivate : For users to activate their assignments.SelfDeactivate : For users to deactivate their active assignments.SelfExtend : For users to request to extend their expiring assignments.SelfRenew : For users to request to renew their expired assignments.
|
principalId |
String |
Identifier of the principal to which the assignment is being granted to. |
roleDefinitionId |
String |
Identifier of the unifiedRoleDefinition the assignment is for. Read only. |
directoryScopeId |
String |
Identifier of the directory object representing the scope of the assignment. The scope of an assignment determines the set of resources for which the principal has been granted access. Directory scopes are shared scopes stored in the directory that are understood by multiple applications. Use / for tenant-wide scope. Use appScopeId to limit the scope to an application only. |
appScopeId |
String |
Identifier of the app-specific scope when the assignment scope is app-specific. The scope of an assignment determines the set of resources for which the principal has been granted access. App scopes are scopes that are defined and understood by this application only. Use / for tenant-wide app scopes. Use directoryScopeId to limit the scope to particular directory objects, for example, administrative units. |
isValidationOnly |
Boolean |
Specifies whether the call is a validation or an actual call. Only set this property if you want to check whether an activation is subject to additional rules like MFA before actually submitting the request. |
targetScheduleId |
String |
ID of the schedule object attached to the assignment. |
justification |
String |
A message provided by users and administrators when create the request about why it is needed. |
scheduleInfo |
requestSchedule |
The schedule object of the role assignment request. |
ticketInfo |
ticketInfo |
The ticketInfo object attached to the role assignment request which includes details of the ticket number and ticket system. |
Response
If successful, this method returns a 201 Created
response code and an unifiedRoleAssignmentScheduleRequest object in the response body.
When the calling user was not challenged for multifactor authentication during their sign in session, a request with the SelfActivate action fails and returns a 400 Bad request
response code.
Examples
Example 1: Admin assigning a directory role to a principal
Request
In the following request, the admin creates a request to assign a role identified by fdd7a751-b60b-444a-984c-02652fe8fa1c
to a principal identified by id 07706ff1-46c7-4847-ae33-3003830675a1
. The scope of their role is all directory objects in the tenant and the assignment is permanent, that is, it doesn't expire.
POST https://graph.microsoft.com/beta/roleManagement/directory/roleAssignmentScheduleRequests/
Content-Type: application/json
{
"action": "AdminAssign",
"justification": "Assign User Admin to IT Helpdesk (User) group",
"roleDefinitionId": "fdd7a751-b60b-444a-984c-02652fe8fa1c",
"directoryScopeId": "/",
"principalId": "07706ff1-46c7-4847-ae33-3003830675a1",
"scheduleInfo": {
"startDateTime": "2021-07-01T00:00:00Z",
"expiration": {
"type": "NoExpiration"
}
}
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models;
var requestBody = new UnifiedRoleAssignmentScheduleRequest
{
Action = "AdminAssign",
Justification = "Assign User Admin to IT Helpdesk (User) group",
RoleDefinitionId = "fdd7a751-b60b-444a-984c-02652fe8fa1c",
DirectoryScopeId = "/",
PrincipalId = "07706ff1-46c7-4847-ae33-3003830675a1",
ScheduleInfo = new RequestSchedule
{
StartDateTime = DateTimeOffset.Parse("2021-07-01T00:00:00Z"),
Expiration = new ExpirationPattern
{
Type = ExpirationPatternType.NoExpiration,
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.RoleManagement.Directory.RoleAssignmentScheduleRequests.PostAsync(requestBody);
mgc-beta role-management directory role-assignment-schedule-requests create --body '{\
"action": "AdminAssign",\
"justification": "Assign User Admin to IT Helpdesk (User) group",\
"roleDefinitionId": "fdd7a751-b60b-444a-984c-02652fe8fa1c",\
"directoryScopeId": "/",\
"principalId": "07706ff1-46c7-4847-ae33-3003830675a1",\
"scheduleInfo": {\
"startDateTime": "2021-07-01T00:00:00Z",\
"expiration": {\
"type": "NoExpiration"\
}\
}\
}\
'
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewUnifiedRoleAssignmentScheduleRequest()
action := "AdminAssign"
requestBody.SetAction(&action)
justification := "Assign User Admin to IT Helpdesk (User) group"
requestBody.SetJustification(&justification)
roleDefinitionId := "fdd7a751-b60b-444a-984c-02652fe8fa1c"
requestBody.SetRoleDefinitionId(&roleDefinitionId)
directoryScopeId := "/"
requestBody.SetDirectoryScopeId(&directoryScopeId)
principalId := "07706ff1-46c7-4847-ae33-3003830675a1"
requestBody.SetPrincipalId(&principalId)
scheduleInfo := graphmodels.NewRequestSchedule()
startDateTime , err := time.Parse(time.RFC3339, "2021-07-01T00:00:00Z")
scheduleInfo.SetStartDateTime(&startDateTime)
expiration := graphmodels.NewExpirationPattern()
type := graphmodels.NOEXPIRATION_EXPIRATIONPATTERNTYPE
expiration.SetType(&type)
scheduleInfo.SetExpiration(expiration)
requestBody.SetScheduleInfo(scheduleInfo)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
roleAssignmentScheduleRequests, err := graphClient.RoleManagement().Directory().RoleAssignmentScheduleRequests().Post(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
UnifiedRoleAssignmentScheduleRequest unifiedRoleAssignmentScheduleRequest = new UnifiedRoleAssignmentScheduleRequest();
unifiedRoleAssignmentScheduleRequest.setAction("AdminAssign");
unifiedRoleAssignmentScheduleRequest.setJustification("Assign User Admin to IT Helpdesk (User) group");
unifiedRoleAssignmentScheduleRequest.setRoleDefinitionId("fdd7a751-b60b-444a-984c-02652fe8fa1c");
unifiedRoleAssignmentScheduleRequest.setDirectoryScopeId("/");
unifiedRoleAssignmentScheduleRequest.setPrincipalId("07706ff1-46c7-4847-ae33-3003830675a1");
RequestSchedule scheduleInfo = new RequestSchedule();
OffsetDateTime startDateTime = OffsetDateTime.parse("2021-07-01T00:00:00Z");
scheduleInfo.setStartDateTime(startDateTime);
ExpirationPattern expiration = new ExpirationPattern();
expiration.setType(ExpirationPatternType.NoExpiration);
scheduleInfo.setExpiration(expiration);
unifiedRoleAssignmentScheduleRequest.setScheduleInfo(scheduleInfo);
UnifiedRoleAssignmentScheduleRequest result = graphClient.roleManagement().directory().roleAssignmentScheduleRequests().post(unifiedRoleAssignmentScheduleRequest);
const options = {
authProvider,
};
const client = Client.init(options);
const unifiedRoleAssignmentScheduleRequest = {
action: 'AdminAssign',
justification: 'Assign User Admin to IT Helpdesk (User) group',
roleDefinitionId: 'fdd7a751-b60b-444a-984c-02652fe8fa1c',
directoryScopeId: '/',
principalId: '07706ff1-46c7-4847-ae33-3003830675a1',
scheduleInfo: {
startDateTime: '2021-07-01T00:00:00Z',
expiration: {
type: 'NoExpiration'
}
}
};
await client.api('/roleManagement/directory/roleAssignmentScheduleRequests/')
.version('beta')
.post(unifiedRoleAssignmentScheduleRequest);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Models\UnifiedRoleAssignmentScheduleRequest;
use Microsoft\Graph\Beta\Generated\Models\RequestSchedule;
use Microsoft\Graph\Beta\Generated\Models\ExpirationPattern;
use Microsoft\Graph\Beta\Generated\Models\ExpirationPatternType;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new UnifiedRoleAssignmentScheduleRequest();
$requestBody->setAction('AdminAssign');
$requestBody->setJustification('Assign User Admin to IT Helpdesk (User) group');
$requestBody->setRoleDefinitionId('fdd7a751-b60b-444a-984c-02652fe8fa1c');
$requestBody->setDirectoryScopeId('/');
$requestBody->setPrincipalId('07706ff1-46c7-4847-ae33-3003830675a1');
$scheduleInfo = new RequestSchedule();
$scheduleInfo->setStartDateTime(new \DateTime('2021-07-01T00:00:00Z'));
$scheduleInfoExpiration = new ExpirationPattern();
$scheduleInfoExpiration->setType(new ExpirationPatternType('noExpiration'));
$scheduleInfo->setExpiration($scheduleInfoExpiration);
$requestBody->setScheduleInfo($scheduleInfo);
$result = $graphServiceClient->roleManagement()->directory()->roleAssignmentScheduleRequests()->post($requestBody)->wait();
Import-Module Microsoft.Graph.Beta.Identity.Governance
$params = @{
action = "AdminAssign"
justification = "Assign User Admin to IT Helpdesk (User) group"
roleDefinitionId = "fdd7a751-b60b-444a-984c-02652fe8fa1c"
directoryScopeId = "/"
principalId = "07706ff1-46c7-4847-ae33-3003830675a1"
scheduleInfo = @{
startDateTime = [System.DateTime]::Parse("2021-07-01T00:00:00Z")
expiration = @{
type = "NoExpiration"
}
}
}
New-MgBetaRoleManagementDirectoryRoleAssignmentScheduleRequest -BodyParameter $params
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.models.unified_role_assignment_schedule_request import UnifiedRoleAssignmentScheduleRequest
from msgraph_beta.generated.models.request_schedule import RequestSchedule
from msgraph_beta.generated.models.expiration_pattern import ExpirationPattern
from msgraph_beta.generated.models.expiration_pattern_type import ExpirationPatternType
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = UnifiedRoleAssignmentScheduleRequest(
action = "AdminAssign",
justification = "Assign User Admin to IT Helpdesk (User) group",
role_definition_id = "fdd7a751-b60b-444a-984c-02652fe8fa1c",
directory_scope_id = "/",
principal_id = "07706ff1-46c7-4847-ae33-3003830675a1",
schedule_info = RequestSchedule(
start_date_time = "2021-07-01T00:00:00Z",
expiration = ExpirationPattern(
type = ExpirationPatternType.NoExpiration,
),
),
)
result = await graph_client.role_management.directory.role_assignment_schedule_requests.post(request_body)
Response
The following example shows the response.
Note: The response object shown here might be shortened for readability.
HTTP/1.1 201 Created
Content-Type: application/json
{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#roleManagement/directory/roleAssignmentScheduleRequests/$entity",
"id": "b5a22921-656a-4429-9c4e-59a5f576614d",
"status": "Provisioned",
"createdDateTime": "2021-07-27T09:18:40.2029365Z",
"completedDateTime": "2021-07-27T09:18:42.7811184Z",
"approvalId": null,
"customData": null,
"action": "AdminAssign",
"principalId": "07706ff1-46c7-4847-ae33-3003830675a1",
"roleDefinitionId": "fdd7a751-b60b-444a-984c-02652fe8fa1c",
"directoryScopeId": "/",
"appScopeId": null,
"isValidationOnly": false,
"targetScheduleId": "b5a22921-656a-4429-9c4e-59a5f576614d",
"justification": "Assign User Admin to IT Helpdesk (User) group",
"createdBy": {
"application": null,
"device": null,
"user": {
"displayName": null,
"id": "fc9a2c2b-1ddc-486d-a211-5fe8ca77fa1f"
}
},
"scheduleInfo": {
"startDateTime": "2021-07-27T09:18:42.7811184Z",
"recurrence": null,
"expiration": {
"type": "noExpiration",
"endDateTime": null,
"duration": null
}
},
"ticketInfo": {
"ticketNumber": null,
"ticketSystem": null
}
}
Example 2: User activating their eligible role
Request
In the following request, a user identified by principalId c6ad1942-4afa-47f8-8d48-afb5d8d69d2f
activates their own eligible role identified by 9b895d92-2cd3-44c7-9d02-a6ac2d5ea5c3
. The scope of their role is all directory objects in the tenant and the assignment is for five hours. To run this request, the calling user must have multifactor authentication (MFA) enforced, and running the query in a session in which they were challenged for MFA.
POST https://graph.microsoft.com/beta/roleManagement/directory/roleAssignmentScheduleRequests/
Content-Type: application/json
{
"action": "SelfActivate",
"principalId": "c6ad1942-4afa-47f8-8d48-afb5d8d69d2f",
"roleDefinitionId": "9b895d92-2cd3-44c7-9d02-a6ac2d5ea5c3",
"directoryScopeId": "/",
"justification": "Need to update app roles for selected apps.",
"scheduleInfo": {
"startDateTime": "2021-08-17T17:40:00.000Z",
"expiration": {
"type": "AfterDuration",
"duration": "PT5H"
}
},
"ticketInfo": {
"ticketNumber": "CONTOSO:Normal-67890",
"ticketSystem": "MS Project"
}
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models;
var requestBody = new UnifiedRoleAssignmentScheduleRequest
{
Action = "SelfActivate",
PrincipalId = "c6ad1942-4afa-47f8-8d48-afb5d8d69d2f",
RoleDefinitionId = "9b895d92-2cd3-44c7-9d02-a6ac2d5ea5c3",
DirectoryScopeId = "/",
Justification = "Need to update app roles for selected apps.",
ScheduleInfo = new RequestSchedule
{
StartDateTime = DateTimeOffset.Parse("2021-08-17T17:40:00.000Z"),
Expiration = new ExpirationPattern
{
Type = ExpirationPatternType.AfterDuration,
Duration = TimeSpan.Parse("PT5H"),
},
},
TicketInfo = new TicketInfo
{
TicketNumber = "CONTOSO:Normal-67890",
TicketSystem = "MS Project",
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.RoleManagement.Directory.RoleAssignmentScheduleRequests.PostAsync(requestBody);
mgc-beta role-management directory role-assignment-schedule-requests create --body '{\
"action": "SelfActivate",\
"principalId": "c6ad1942-4afa-47f8-8d48-afb5d8d69d2f",\
"roleDefinitionId": "9b895d92-2cd3-44c7-9d02-a6ac2d5ea5c3",\
"directoryScopeId": "/",\
"justification": "Need to update app roles for selected apps.",\
"scheduleInfo": {\
"startDateTime": "2021-08-17T17:40:00.000Z",\
"expiration": {\
"type": "AfterDuration",\
"duration": "PT5H"\
}\
},\
"ticketInfo": {\
"ticketNumber": "CONTOSO:Normal-67890",\
"ticketSystem": "MS Project"\
}\
}\
'
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewUnifiedRoleAssignmentScheduleRequest()
action := "SelfActivate"
requestBody.SetAction(&action)
principalId := "c6ad1942-4afa-47f8-8d48-afb5d8d69d2f"
requestBody.SetPrincipalId(&principalId)
roleDefinitionId := "9b895d92-2cd3-44c7-9d02-a6ac2d5ea5c3"
requestBody.SetRoleDefinitionId(&roleDefinitionId)
directoryScopeId := "/"
requestBody.SetDirectoryScopeId(&directoryScopeId)
justification := "Need to update app roles for selected apps."
requestBody.SetJustification(&justification)
scheduleInfo := graphmodels.NewRequestSchedule()
startDateTime , err := time.Parse(time.RFC3339, "2021-08-17T17:40:00.000Z")
scheduleInfo.SetStartDateTime(&startDateTime)
expiration := graphmodels.NewExpirationPattern()
type := graphmodels.AFTERDURATION_EXPIRATIONPATTERNTYPE
expiration.SetType(&type)
duration , err := abstractions.ParseISODuration("PT5H")
expiration.SetDuration(&duration)
scheduleInfo.SetExpiration(expiration)
requestBody.SetScheduleInfo(scheduleInfo)
ticketInfo := graphmodels.NewTicketInfo()
ticketNumber := "CONTOSO:Normal-67890"
ticketInfo.SetTicketNumber(&ticketNumber)
ticketSystem := "MS Project"
ticketInfo.SetTicketSystem(&ticketSystem)
requestBody.SetTicketInfo(ticketInfo)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
roleAssignmentScheduleRequests, err := graphClient.RoleManagement().Directory().RoleAssignmentScheduleRequests().Post(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
UnifiedRoleAssignmentScheduleRequest unifiedRoleAssignmentScheduleRequest = new UnifiedRoleAssignmentScheduleRequest();
unifiedRoleAssignmentScheduleRequest.setAction("SelfActivate");
unifiedRoleAssignmentScheduleRequest.setPrincipalId("c6ad1942-4afa-47f8-8d48-afb5d8d69d2f");
unifiedRoleAssignmentScheduleRequest.setRoleDefinitionId("9b895d92-2cd3-44c7-9d02-a6ac2d5ea5c3");
unifiedRoleAssignmentScheduleRequest.setDirectoryScopeId("/");
unifiedRoleAssignmentScheduleRequest.setJustification("Need to update app roles for selected apps.");
RequestSchedule scheduleInfo = new RequestSchedule();
OffsetDateTime startDateTime = OffsetDateTime.parse("2021-08-17T17:40:00.000Z");
scheduleInfo.setStartDateTime(startDateTime);
ExpirationPattern expiration = new ExpirationPattern();
expiration.setType(ExpirationPatternType.AfterDuration);
PeriodAndDuration duration = PeriodAndDuration.ofDuration(Duration.parse("PT5H"));
expiration.setDuration(duration);
scheduleInfo.setExpiration(expiration);
unifiedRoleAssignmentScheduleRequest.setScheduleInfo(scheduleInfo);
TicketInfo ticketInfo = new TicketInfo();
ticketInfo.setTicketNumber("CONTOSO:Normal-67890");
ticketInfo.setTicketSystem("MS Project");
unifiedRoleAssignmentScheduleRequest.setTicketInfo(ticketInfo);
UnifiedRoleAssignmentScheduleRequest result = graphClient.roleManagement().directory().roleAssignmentScheduleRequests().post(unifiedRoleAssignmentScheduleRequest);
const options = {
authProvider,
};
const client = Client.init(options);
const unifiedRoleAssignmentScheduleRequest = {
action: 'SelfActivate',
principalId: 'c6ad1942-4afa-47f8-8d48-afb5d8d69d2f',
roleDefinitionId: '9b895d92-2cd3-44c7-9d02-a6ac2d5ea5c3',
directoryScopeId: '/',
justification: 'Need to update app roles for selected apps.',
scheduleInfo: {
startDateTime: '2021-08-17T17:40:00.000Z',
expiration: {
type: 'AfterDuration',
duration: 'PT5H'
}
},
ticketInfo: {
ticketNumber: 'CONTOSO:Normal-67890',
ticketSystem: 'MS Project'
}
};
await client.api('/roleManagement/directory/roleAssignmentScheduleRequests/')
.version('beta')
.post(unifiedRoleAssignmentScheduleRequest);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Models\UnifiedRoleAssignmentScheduleRequest;
use Microsoft\Graph\Beta\Generated\Models\RequestSchedule;
use Microsoft\Graph\Beta\Generated\Models\ExpirationPattern;
use Microsoft\Graph\Beta\Generated\Models\ExpirationPatternType;
use Microsoft\Graph\Beta\Generated\Models\TicketInfo;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new UnifiedRoleAssignmentScheduleRequest();
$requestBody->setAction('SelfActivate');
$requestBody->setPrincipalId('c6ad1942-4afa-47f8-8d48-afb5d8d69d2f');
$requestBody->setRoleDefinitionId('9b895d92-2cd3-44c7-9d02-a6ac2d5ea5c3');
$requestBody->setDirectoryScopeId('/');
$requestBody->setJustification('Need to update app roles for selected apps.');
$scheduleInfo = new RequestSchedule();
$scheduleInfo->setStartDateTime(new \DateTime('2021-08-17T17:40:00.000Z'));
$scheduleInfoExpiration = new ExpirationPattern();
$scheduleInfoExpiration->setType(new ExpirationPatternType('afterDuration'));
$scheduleInfoExpiration->setDuration(new \DateInterval('PT5H'));
$scheduleInfo->setExpiration($scheduleInfoExpiration);
$requestBody->setScheduleInfo($scheduleInfo);
$ticketInfo = new TicketInfo();
$ticketInfo->setTicketNumber('CONTOSO:Normal-67890');
$ticketInfo->setTicketSystem('MS Project');
$requestBody->setTicketInfo($ticketInfo);
$result = $graphServiceClient->roleManagement()->directory()->roleAssignmentScheduleRequests()->post($requestBody)->wait();
Import-Module Microsoft.Graph.Beta.Identity.Governance
$params = @{
action = "SelfActivate"
principalId = "c6ad1942-4afa-47f8-8d48-afb5d8d69d2f"
roleDefinitionId = "9b895d92-2cd3-44c7-9d02-a6ac2d5ea5c3"
directoryScopeId = "/"
justification = "Need to update app roles for selected apps."
scheduleInfo = @{
startDateTime = [System.DateTime]::Parse("2021-08-17T17:40:00.000Z")
expiration = @{
type = "AfterDuration"
duration = "PT5H"
}
}
ticketInfo = @{
ticketNumber = "CONTOSO:Normal-67890"
ticketSystem = "MS Project"
}
}
New-MgBetaRoleManagementDirectoryRoleAssignmentScheduleRequest -BodyParameter $params
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.models.unified_role_assignment_schedule_request import UnifiedRoleAssignmentScheduleRequest
from msgraph_beta.generated.models.request_schedule import RequestSchedule
from msgraph_beta.generated.models.expiration_pattern import ExpirationPattern
from msgraph_beta.generated.models.expiration_pattern_type import ExpirationPatternType
from msgraph_beta.generated.models.ticket_info import TicketInfo
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = UnifiedRoleAssignmentScheduleRequest(
action = "SelfActivate",
principal_id = "c6ad1942-4afa-47f8-8d48-afb5d8d69d2f",
role_definition_id = "9b895d92-2cd3-44c7-9d02-a6ac2d5ea5c3",
directory_scope_id = "/",
justification = "Need to update app roles for selected apps.",
schedule_info = RequestSchedule(
start_date_time = "2021-08-17T17:40:00.000Z",
expiration = ExpirationPattern(
type = ExpirationPatternType.AfterDuration,
duration = "PT5H",
),
),
ticket_info = TicketInfo(
ticket_number = "CONTOSO:Normal-67890",
ticket_system = "MS Project",
),
)
result = await graph_client.role_management.directory.role_assignment_schedule_requests.post(request_body)
Response
The following example shows the response.
Note: The response object shown here might be shortened for readability.
HTTP/1.1 201 Created
Content-Type: application/json
{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#roleManagement/directory/roleAssignmentScheduleRequests/$entity",
"id": "163daf73-8746-4996-87de-ab71dc624bf9",
"status": "Granted",
"createdDateTime": "2021-08-17T17:39:36.7040696Z",
"completedDateTime": "2021-08-17T17:40:00Z",
"approvalId": null,
"customData": null,
"action": "SelfActivate",
"principalId": "c6ad1942-4afa-47f8-8d48-afb5d8d69d2f",
"roleDefinitionId": "9b895d92-2cd3-44c7-9d02-a6ac2d5ea5c3",
"directoryScopeId": "/",
"appScopeId": null,
"isValidationOnly": false,
"targetScheduleId": "163daf73-8746-4996-87de-ab71dc624bf9",
"justification": "Need to update app roles for selected apps.",
"createdBy": {
"application": null,
"device": null,
"user": {
"displayName": null,
"id": "c6ad1942-4afa-47f8-8d48-afb5d8d69d2f"
}
},
"scheduleInfo": {
"startDateTime": "2021-08-17T17:40:00Z",
"recurrence": null,
"expiration": {
"type": "afterDuration",
"endDateTime": null,
"duration": "PT5H"
}
},
"ticketInfo": {
"ticketNumber": "CONTOSO:Normal-67890",
"ticketSystem": "MS Project"
}
}