Les API sous la version /beta dans Microsoft Graph sont susceptibles d’être modifiées. L’utilisation de ces API dans des applications de production n’est pas prise en charge. Pour déterminer si une API est disponible dans v1.0, utilisez le sélecteur Version .
Définir un message de présence status pour un utilisateur. Une date et une heure d’expiration facultatives peuvent être fournies.
Contient le message de présence status de l’utilisateur.
Réponse
Si elle réussit, cette méthode renvoie un code de réponse 200 OK.
Exemples
Exemple 1 : Définir status message avec la date d’expiration
La requête suivante définit la présence status message sur « Hey je suis actuellement en réunion ». pour l’utilisateur fa8bf3dc-eca7-46b7-bad1-db199b62afc3, avec l’expiration le 2022-10-18 at 17:05:33.2079781 Pacific Standard Time.
POST https://graph.microsoft.com/beta/users/fa8bf3dc-eca7-46b7-bad1-db199b62afc3/presence/setStatusMessage
Content-Type: application/json
{
"statusMessage": {
"message": {
"content": "Hey I'm currently in a meeting.",
"contentType": "text"
},
"expiryDateTime": {
"dateTime": "2022-10-18T17:05:33.2079781",
"timeZone": "Pacific Standard Time"
}
}
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Users.Item.Presence.SetStatusMessage;
using Microsoft.Graph.Beta.Models;
var requestBody = new SetStatusMessagePostRequestBody
{
StatusMessage = new PresenceStatusMessage
{
Message = new ItemBody
{
Content = "Hey I'm currently in a meeting.",
ContentType = BodyType.Text,
},
ExpiryDateTime = new DateTimeTimeZone
{
DateTime = "2022-10-18T17:05:33.2079781",
TimeZone = "Pacific Standard Time",
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
await graphClient.Users["{user-id}"].Presence.SetStatusMessage.PostAsync(requestBody);
// 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"
graphusers "github.com/microsoftgraph/msgraph-beta-sdk-go/users"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
//other-imports
)
requestBody := graphusers.NewSetStatusMessagePostRequestBody()
statusMessage := graphmodels.NewPresenceStatusMessage()
message := graphmodels.NewItemBody()
content := "Hey I'm currently in a meeting."
message.SetContent(&content)
contentType := graphmodels.TEXT_BODYTYPE
message.SetContentType(&contentType)
statusMessage.SetMessage(message)
expiryDateTime := graphmodels.NewDateTimeTimeZone()
dateTime := "2022-10-18T17:05:33.2079781"
expiryDateTime.SetDateTime(&dateTime)
timeZone := "Pacific Standard Time"
expiryDateTime.SetTimeZone(&timeZone)
statusMessage.SetExpiryDateTime(expiryDateTime)
requestBody.SetStatusMessage(statusMessage)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
graphClient.Users().ByUserId("user-id").Presence().SetStatusMessage().Post(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
com.microsoft.graph.beta.users.item.presence.setstatusmessage.SetStatusMessagePostRequestBody setStatusMessagePostRequestBody = new com.microsoft.graph.beta.users.item.presence.setstatusmessage.SetStatusMessagePostRequestBody();
PresenceStatusMessage statusMessage = new PresenceStatusMessage();
ItemBody message = new ItemBody();
message.setContent("Hey I'm currently in a meeting.");
message.setContentType(BodyType.Text);
statusMessage.setMessage(message);
DateTimeTimeZone expiryDateTime = new DateTimeTimeZone();
expiryDateTime.setDateTime("2022-10-18T17:05:33.2079781");
expiryDateTime.setTimeZone("Pacific Standard Time");
statusMessage.setExpiryDateTime(expiryDateTime);
setStatusMessagePostRequestBody.setStatusMessage(statusMessage);
graphClient.users().byUserId("{user-id}").presence().setStatusMessage().post(setStatusMessagePostRequestBody);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Users\Item\Presence\SetStatusMessage\SetStatusMessagePostRequestBody;
use Microsoft\Graph\Beta\Generated\Models\PresenceStatusMessage;
use Microsoft\Graph\Beta\Generated\Models\ItemBody;
use Microsoft\Graph\Beta\Generated\Models\BodyType;
use Microsoft\Graph\Beta\Generated\Models\DateTimeTimeZone;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new SetStatusMessagePostRequestBody();
$statusMessage = new PresenceStatusMessage();
$statusMessageMessage = new ItemBody();
$statusMessageMessage->setContent('Hey I\'m currently in a meeting.');
$statusMessageMessage->setContentType(new BodyType('text'));
$statusMessage->setMessage($statusMessageMessage);
$statusMessageExpiryDateTime = new DateTimeTimeZone();
$statusMessageExpiryDateTime->setDateTime('2022-10-18T17:05:33.2079781');
$statusMessageExpiryDateTime->setTimeZone('Pacific Standard Time');
$statusMessage->setExpiryDateTime($statusMessageExpiryDateTime);
$requestBody->setStatusMessage($statusMessage);
$graphServiceClient->users()->byUserId('user-id')->presence()->setStatusMessage()->post($requestBody)->wait();
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.users.item.presence.set_status_message.set_status_message_post_request_body import SetStatusMessagePostRequestBody
from msgraph_beta.generated.models.presence_status_message import PresenceStatusMessage
from msgraph_beta.generated.models.item_body import ItemBody
from msgraph_beta.generated.models.body_type import BodyType
from msgraph_beta.generated.models.date_time_time_zone import DateTimeTimeZone
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = SetStatusMessagePostRequestBody(
status_message = PresenceStatusMessage(
message = ItemBody(
content = "Hey I'm currently in a meeting.",
content_type = BodyType.Text,
),
expiry_date_time = DateTimeTimeZone(
date_time = "2022-10-18T17:05:33.2079781",
time_zone = "Pacific Standard Time",
),
),
)
await graph_client.users.by_user_id('user-id').presence.set_status_message.post(request_body)
Exemple 2 : Définir status message d’un autre utilisateur
La requête suivante définit le message de présence status comme « Je suis disponible maintenant » pour l’utilisateur fa8bf3dc-eca7-46b7-bad1-db199b62afc3. Dans l’exemple 3, les informations de présence de l’utilisateur fa8bf3dc-eca7-46b7-bad1-db199b62afc3 sont obtenues pour le compte d’un autre utilisateur via une demande getPresence .
POST https://graph.microsoft.com/beta/users/fa8bf3dc-eca7-46b7-bad1-db199b62afc3/presence/setStatusMessage
Content-Type: application/json
{
"statusMessage": {
"message": {
"content": "Hey I am available now",
"contentType": "text"
}
}
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Users.Item.Presence.SetStatusMessage;
using Microsoft.Graph.Beta.Models;
var requestBody = new SetStatusMessagePostRequestBody
{
StatusMessage = new PresenceStatusMessage
{
Message = new ItemBody
{
Content = "Hey I am available now",
ContentType = BodyType.Text,
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
await graphClient.Users["{user-id}"].Presence.SetStatusMessage.PostAsync(requestBody);
// 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"
graphusers "github.com/microsoftgraph/msgraph-beta-sdk-go/users"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
//other-imports
)
requestBody := graphusers.NewSetStatusMessagePostRequestBody()
statusMessage := graphmodels.NewPresenceStatusMessage()
message := graphmodels.NewItemBody()
content := "Hey I am available now"
message.SetContent(&content)
contentType := graphmodels.TEXT_BODYTYPE
message.SetContentType(&contentType)
statusMessage.SetMessage(message)
requestBody.SetStatusMessage(statusMessage)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
graphClient.Users().ByUserId("user-id").Presence().SetStatusMessage().Post(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
com.microsoft.graph.beta.users.item.presence.setstatusmessage.SetStatusMessagePostRequestBody setStatusMessagePostRequestBody = new com.microsoft.graph.beta.users.item.presence.setstatusmessage.SetStatusMessagePostRequestBody();
PresenceStatusMessage statusMessage = new PresenceStatusMessage();
ItemBody message = new ItemBody();
message.setContent("Hey I am available now");
message.setContentType(BodyType.Text);
statusMessage.setMessage(message);
setStatusMessagePostRequestBody.setStatusMessage(statusMessage);
graphClient.users().byUserId("{user-id}").presence().setStatusMessage().post(setStatusMessagePostRequestBody);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Users\Item\Presence\SetStatusMessage\SetStatusMessagePostRequestBody;
use Microsoft\Graph\Beta\Generated\Models\PresenceStatusMessage;
use Microsoft\Graph\Beta\Generated\Models\ItemBody;
use Microsoft\Graph\Beta\Generated\Models\BodyType;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new SetStatusMessagePostRequestBody();
$statusMessage = new PresenceStatusMessage();
$statusMessageMessage = new ItemBody();
$statusMessageMessage->setContent('Hey I am available now');
$statusMessageMessage->setContentType(new BodyType('text'));
$statusMessage->setMessage($statusMessageMessage);
$requestBody->setStatusMessage($statusMessage);
$graphServiceClient->users()->byUserId('user-id')->presence()->setStatusMessage()->post($requestBody)->wait();
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.users.item.presence.set_status_message.set_status_message_post_request_body import SetStatusMessagePostRequestBody
from msgraph_beta.generated.models.presence_status_message import PresenceStatusMessage
from msgraph_beta.generated.models.item_body import ItemBody
from msgraph_beta.generated.models.body_type import BodyType
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = SetStatusMessagePostRequestBody(
status_message = PresenceStatusMessage(
message = ItemBody(
content = "Hey I am available now",
content_type = BodyType.Text,
),
),
)
await graph_client.users.by_user_id('user-id').presence.set_status_message.post(request_body)
Exemple 3 : Obtenir la présence d’un autre utilisateur
Cet exemple suit l’exemple 2. Les informations de présence de l’utilisateur fa8bf3dc-eca7-46b7-bad1-db199b62afc3 sont obtenues pour le compte d’un autre utilisateur via une demande getPresence .
GET https://graph.microsoft.com/beta/users/fa8bf3dc-eca7-46b7-bad1-db199b62afc3/presence
// 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}"].Presence.GetAsync();
// 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"
//other-imports
)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
presence, err := graphClient.Users().ByUserId("user-id").Presence().Get(context.Background(), nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
Presence result = graphClient.users().byUserId("{user-id}").presence().get();
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta 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').presence.get()
Étant donné que cette requête obtient la présence status pour un autre utilisateur, les statusMessage.expiryDateTime propriétés et statusMessage.publishedDateTime ne sont pas incluses dans le corps de la réponse.
HTTP/1.1 200 OK
Content-Type: application/json
{
"id": "fa8bf3dc-eca7-46b7-bad1-db199b62afc3",
"availability": "Available",
"activity": "Available",
"outOfOfficeSettings": {
"message": null,
"isOutOfOffice": false
},
"statusMessage": {
"message": {
"content": "Hey I am available now",
"contentType": "text"
}
}
}