cloudCommunications: getPresencesByUserId
Article
02/18/2023
6 contributors
Feedback
In this article
Namespace: microsoft.graph
Get the presence information for multiple users.
Permissions
One of the following permissions is required to call these APIs. To learn more, including how to choose permissions, see Permissions .
Permission type
Permissions (from least to most privileged)
Delegated (work or school account)
Presence.Read.All
Delegated (personal Microsoft account)
Not Supported.
Application
Not Supported.
Note:
Maximum of 650 user IDs are supported per API request.
The maximum request rate of this API is 1500 API requests in a 30 second period, per application per tenant.
HTTP Request
POST /communications/getPresencesByUserId
Name
Description
Authorization
Bearer {token}. Required.
Content-type
application/json. Required.
Request body
In the request body, provide a JSON object with the following parameter.
Parameter
Type
Description
ids
String collection
The user object IDs.
Response
If successful, this method returns a 200 OK
response code and a collection of presence objects in the response body.
Examples
Request
The following example shows a request.
POST https://graph.microsoft.com/v1.0/communications/getPresencesByUserId
Content-Type: application/json
{
"ids": ["fa8bf3dc-eca7-46b7-bad1-db199b62afc3", "66825e03-7ef5-42da-9069-724602c31f6b"]
}
// Code snippets are only available for the latest version. Current version is 5.x
var graphClient = new GraphServiceClient(requestAdapter);
var requestBody = new Microsoft.Graph.Communications.GetPresencesByUserId.GetPresencesByUserIdPostRequestBody
{
Ids = new List<string>
{
"fa8bf3dc-eca7-46b7-bad1-db199b62afc3",
"66825e03-7ef5-42da-9069-724602c31f6b",
},
};
var result = await graphClient.Communications.GetPresencesByUserId.PostAsync(requestBody);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-sdk-go/Communications/GetPresencesByUserId"
//other-imports
)
graphClient := msgraphsdk.NewGraphServiceClientWithCredentials(cred, scopes)
requestBody := graphmodels.NewGetPresencesByUserIdPostRequestBody()
ids := []string {
"fa8bf3dc-eca7-46b7-bad1-db199b62afc3",
"66825e03-7ef5-42da-9069-724602c31f6b",
}
requestBody.SetIds(ids)
result, err := graphClient.Communications().GetPresencesByUserId().Post(context.Background(), requestBody, nil)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
LinkedList<String> idsList = new LinkedList<String>();
idsList.add("fa8bf3dc-eca7-46b7-bad1-db199b62afc3");
idsList.add("66825e03-7ef5-42da-9069-724602c31f6b");
graphClient.communications()
.getPresencesByUserId(CloudCommunicationsGetPresencesByUserIdParameterSet
.newBuilder()
.withIds(idsList)
.build())
.buildRequest()
.post();
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);
const presence = {
ids: ['fa8bf3dc-eca7-46b7-bad1-db199b62afc3', '66825e03-7ef5-42da-9069-724602c31f6b']
};
await client.api('/communications/getPresencesByUserId')
.post(presence);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
<?php
// THIS SNIPPET IS A PREVIEW FOR THE KIOTA BASED SDK. NON-PRODUCTION USE ONLY
$graphServiceClient = new GraphServiceClient($requestAdapter);
$requestBody = new GetPresencesByUserIdPostRequestBody();
$requestBody->setIds(['fa8bf3dc-eca7-46b7-bad1-db199b62afc3', '66825e03-7ef5-42da-9069-724602c31f6b', ]);
$result = $graphServiceClient->communications()->getPresencesByUserId()->post($requestBody);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
Import-Module Microsoft.Graph.CloudCommunications
$params = @{
ids = @(
"fa8bf3dc-eca7-46b7-bad1-db199b62afc3"
"66825e03-7ef5-42da-9069-724602c31f6b"
)
}
Get-MgCommunicationPresenceByUserId -BodyParameter $params
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 objects might be shortened for readability. All the properties will be returned from an actual call.
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 1574
{
"value": [{
"id": "fa8bf3dc-eca7-46b7-bad1-db199b62afc3",
"availability": "Busy",
"activity": "InAMeeting"
},
{
"id": "66825e03-7ef5-42da-9069-724602c31f6b",
"availability": "Away",
"activity": "Away"
}
]
}