Namespace: microsoft.graph
Get a list of all the roles assigned to a user in Viva Engage.
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) |
EngagementRole.Read |
EngagementRole.ReadWrite.All |
| Delegated (personal Microsoft account) |
Not supported. |
Not supported. |
| Application |
EngagementRole.Read.All |
EngagementRole.ReadWrite.All |
Note
Calling the /me endpoint requires a signed-in user and therefore a delegated permission. Application permissions aren't supported when using the /me endpoint.
HTTP request
GET /users/{userId}/employeeExperience/assignedRoles
GET /me/employeeExperience/assignedRoles
Note: The {userId} represents the office user ID.
Optional query parameters
This method supports the $filter (eq), $select, and $count OData query parameters. For general information, see OData query parameters. Only the displayName and id properties support the $filter parameter.
The following table shows how you can use OData query parameters with this API.
| Description |
HTTP request |
| Filter assigned roles by display name |
GET /users/{userId}/employeeExperience/assignedRoles?$filter=displayName eq 'Corporate Communicator' |
| Get only the id property for a list of assigned roles |
GET /users/{userId}/employeeExperience/assignedRoles?$select=id |
| Include the total count of assigned roles |
GET /users/{userId}/employeeExperience/assignedRoles?$count=true |
Request body
Don't supply a request body for this method.
Response
If successful, this method returns a 200 OK response code and a collection of engagementRole objects in the response body.
Examples
Example 1: Get a list of all the roles assigned to a signed-in user in Viva Engage
The following example shows how to get a list of all the roles assigned to a signed-in user in Viva Engage.
Request
The following example shows a request.
GET https://graph.microsoft.com/v1.0/me/employeeExperience/assignedRoles
// Code snippets are only available for the latest version. Current version is 5.x
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Me.EmployeeExperience.AssignedRoles.GetAsync();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
// 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"
//other-imports
)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
assignedRoles, err := graphClient.Me().EmployeeExperience().AssignedRoles().Get(context.Background(), nil)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
EngagementRoleCollectionResponse result = graphClient.me().employeeExperience().assignedRoles().get();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
const options = {
authProvider,
};
const client = Client.init(options);
let assignedRoles = await client.api('/me/employeeExperience/assignedRoles')
.get();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
<?php
use Microsoft\Graph\GraphServiceClient;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$result = $graphServiceClient->me()->employeeExperience()->assignedRoles()->get()->wait();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
result = await graph_client.me.employee_experience.assigned_roles.get()
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
Response
The following example shows the response.
Note: The response object shown here might be shortened for readability.
HTTP/1.1 200 OK
Content-Type: application/json
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#me/employeeExperience/assignedRoles",
"value": [
{
"id": "ec791927-d09f-4f91-bd76-d3b05e1c1a31",
"displayName": "Network Admin"
},
{
"id": "b0de8e6d-4457-4722-bdc5-5a32a09bf064",
"displayName": "Verified Admin"
},
{
"id": "77aa7d76-bdf6-4cc0-80e2-fd1ac5a28471",
"displayName": "Corporate Communicator"
}
]
}
Example 2: Get a list of all the roles assigned to a user in Viva Engage
The following example shows how to get a list of all the roles assigned to a user in Viva Engage.
Request
The following example shows a request.
GET https://graph.microsoft.com/v1.0/users/e8d9f6a2-1c34-4b7a-9f11-2a4d8b7c9e01/employeeExperience/assignedRoles
// Code snippets are only available for the latest version. Current version is 5.x
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Users["{user-id}"].EmployeeExperience.AssignedRoles.GetAsync();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
// 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"
//other-imports
)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
assignedRoles, err := graphClient.Users().ByUserId("user-id").EmployeeExperience().AssignedRoles().Get(context.Background(), nil)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
EngagementRoleCollectionResponse result = graphClient.users().byUserId("{user-id}").employeeExperience().assignedRoles().get();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
const options = {
authProvider,
};
const client = Client.init(options);
let assignedRoles = await client.api('/users/e8d9f6a2-1c34-4b7a-9f11-2a4d8b7c9e01/employeeExperience/assignedRoles')
.get();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
<?php
use Microsoft\Graph\GraphServiceClient;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$result = $graphServiceClient->users()->byUserId('user-id')->employeeExperience()->assignedRoles()->get()->wait();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
result = await graph_client.users.by_user_id('user-id').employee_experience.assigned_roles.get()
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
Response
The following example shows the response.
Note: The response object shown here might be shortened for readability.
HTTP/1.1 200 OK
Content-Type: application/json
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users/e8d9f6a2-1c34-4b7a-9f11-2a4d8b7c9e01/employeeExperience/assignedRoles",
"value": [
{
"id": "ec791927-d09f-4f91-bd76-d3b05e1c1a31",
"displayName": "Network Admin"
},
{
"id": "b0de8e6d-4457-4722-bdc5-5a32a09bf064",
"displayName": "Verified Admin"
},
{
"id": "77aa7d76-bdf6-4cc0-80e2-fd1ac5a28471",
"displayName": "Corporate Communicator"
}
]
}