Create roleAssignmentScheduleRequests fail with RoleNotFound error.

KlemenS 5 Reputation points
2024-07-01T11:24:10.12+00:00

If we create role definition using HTTP API (same also if using MS Graph Python SDK; client credential OAUTH auth):
https://graph.microsoft.com/v1.0/roleManagement/directory/roleDefinitions

{
    "description": "Role description",
    "displayName": "RoleDefinitionTest",
    "rolePermissions":
    [
        {
            "allowedResourceActions":
            [
                "microsoft.directory/applications/basic/read"
            ]
        }
    ],
    "isEnabled": true
}

Note: Role permission can be anything, the action up is just as an example.
And try to assign a new eligible (or active) role schedule request:
https://graph.microsoft.com/v1.0/roleManagement/directory/roleEligibilityScheduleRequests

{
    "action": "adminAssign",
    "justification": "Assign test...",
    "roleDefinitionId": <ROLEDEFINITIONTEST_UUID>,
    "directoryScopeId": "/",
    "principalId": <SOME_USER__UUID>,
    "scheduleInfo": {
        "startDateTime": "2022-04-10T00:00:00Z",
        "expiration": {
            "type": "afterDateTime",
            "endDateTime": "2024-10-10T00:00:00Z"
        }
    }
}

The request fails with error like:

{
    "error": {
        "code": "RoleNotFound",
        "message": "The role is not found.",
        "innerError": {
            "date": "2024-06-30T12:44:58",
            "request-id": "f81f6d94-77ea-4865-bb34-8201341f5a72",
            "client-request-id": "f81f6d94-77ea-4865-bb34-8201341f5a72"
        }
    }
}

If running same using Powershell MS Graph SDK, it passes. Also if accesing the created role definition throught Entra Admin console and trying just to add some assigments, and then run roleEligibilityScheduleRequests again after some time, the same request passes ok.

Is this expected to work? Is there some other role action needed to be executed prior running roleEligibilityScheduleRequests?

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,343 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.