Wählen Sie für diese API die Als am wenigsten privilegierten Berechtigungen gekennzeichneten Berechtigungen aus. Verwenden Sie nur dann eine Berechtigung mit höheren Berechtigungen , wenn dies für Ihre App erforderlich ist. Ausführliche Informationen zu delegierten Berechtigungen und Anwendungsberechtigungen finden Sie unter Berechtigungstypen. Weitere Informationen zu diesen Berechtigungen finden Sie in der Berechtigungsreferenz.
Enthält die Anwesenheitsnachricht status des Benutzers.
Antwort
Wenn die Methode erfolgreich verläuft, wird der Antwortcode 200 OK zurückgegeben.
Beispiele
Beispiel 1: Festlegen status Nachricht mit Ablaufdatum
Die folgende Anforderung legt die Anwesenheits-status Nachricht als "Hallo, ich bin gerade in einer Besprechung." für den Benutzer fa8bf3dc-eca7-46b7-bad1-db199b62afc3fest, wobei der Ablauf auf lautet2022-10-18 at 17:05:33.2079781 Pacific Standard Time.
POST https://graph.microsoft.com/v1.0/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.Users.Item.Presence.SetStatusMessage;
using Microsoft.Graph.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 $v1.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphusers "github.com/microsoftgraph/msgraph-sdk-go/users"
graphmodels "github.com/microsoftgraph/msgraph-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.users.item.presence.setstatusmessage.SetStatusMessagePostRequestBody setStatusMessagePostRequestBody = new com.microsoft.graph.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\GraphServiceClient;
use Microsoft\Graph\Generated\Users\Item\Presence\SetStatusMessage\SetStatusMessagePostRequestBody;
use Microsoft\Graph\Generated\Models\PresenceStatusMessage;
use Microsoft\Graph\Generated\Models\ItemBody;
use Microsoft\Graph\Generated\Models\BodyType;
use Microsoft\Graph\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 import GraphServiceClient
from msgraph.generated.users.item.presence.set_status_message.set_status_message_post_request_body import SetStatusMessagePostRequestBody
from msgraph.generated.models.presence_status_message import PresenceStatusMessage
from msgraph.generated.models.item_body import ItemBody
from msgraph.generated.models.body_type import BodyType
from msgraph.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)
Beispiel 2: Festlegen status Nachricht eines anderen Benutzers
Die folgende Anforderung legt die Anwesenheitsmeldung status für den Benutzer fa8bf3dc-eca7-46b7-bad1-db199b62afc3als "Hey, ich bin jetzt verfügbar" fest. In Beispiel 3 werden Anwesenheitsinformationen für den Benutzer fa8bf3dc-eca7-46b7-bad1-db199b62afc3 im Namen eines anderen Benutzers über eine getPresence-Anforderung abgerufen.
POST https://graph.microsoft.com/v1.0/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.Users.Item.Presence.SetStatusMessage;
using Microsoft.Graph.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 $v1.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphusers "github.com/microsoftgraph/msgraph-sdk-go/users"
graphmodels "github.com/microsoftgraph/msgraph-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.users.item.presence.setstatusmessage.SetStatusMessagePostRequestBody setStatusMessagePostRequestBody = new com.microsoft.graph.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\GraphServiceClient;
use Microsoft\Graph\Generated\Users\Item\Presence\SetStatusMessage\SetStatusMessagePostRequestBody;
use Microsoft\Graph\Generated\Models\PresenceStatusMessage;
use Microsoft\Graph\Generated\Models\ItemBody;
use Microsoft\Graph\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 import GraphServiceClient
from msgraph.generated.users.item.presence.set_status_message.set_status_message_post_request_body import SetStatusMessagePostRequestBody
from msgraph.generated.models.presence_status_message import PresenceStatusMessage
from msgraph.generated.models.item_body import ItemBody
from msgraph.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)
Beispiel 3: Abrufen der Anwesenheit eines anderen Benutzers
Dieses Beispiel folgt auf Beispiel 2. Anwesenheitsinformationen für einen Benutzer fa8bf3dc-eca7-46b7-bad1-db199b62afc3 werden im Namen eines anderen Benutzers über eine getPresence-Anforderung abgerufen.
GET https://graph.microsoft.com/v1.0/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 $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
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 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()
Da diese Anforderung die Anwesenheits-status für einen anderen Benutzer abruft, sind die statusMessage.expiryDateTime Eigenschaften und statusMessage.publishedDateTime nicht im Antworttext enthalten.
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"
}
}
}