名前空間: microsoft.graph
重要
Microsoft Graph の /beta バージョンの API は変更される可能性があります。 実稼働アプリケーションでこれらの API を使用することは、サポートされていません。 v1.0 で API を使用できるかどうかを確認するには、Version セレクターを使用します。
ユーザーの優先可用性とアクティビティの状態を設定します。 ユーザーの優先プレゼンスが設定されている場合は、ユーザーのプレゼンスが優先プレゼンスになります。
優先プレゼンスは、ユーザーの プレゼンス セッション が少なくとも 1 つ存在する場合にのみ有効になります。 それ以外の場合、ユーザーのプレゼンスはオフラインのままです。
プレゼンス セッションは、 setPresence 操作が成功した結果、またはユーザーが Teams クライアントにサインインした場合に作成できます。
プレゼンス セッションとそのタイムアウトと有効期限について詳しくは、こちらをご覧ください。
この API は、次の国内クラウド展開で使用できます。
| グローバル サービス |
米国政府機関 L4 |
米国政府機関 L5 (DOD) |
21Vianet が運営する中国 |
| ✅ |
❌ |
❌ |
❌ |
アクセス許可
この API の最小特権としてマークされているアクセス許可またはアクセス許可を選択します。
アプリで必要な場合にのみ、より高い特権のアクセス許可またはアクセス許可を使用します。 委任されたアクセス許可とアプリケーションのアクセス許可の詳細については、「アクセス許可の種類」を参照してください。 これらのアクセス許可の詳細については、「アクセス許可のリファレンス」を参照してください。
| アクセス許可の種類 |
最小特権アクセス許可 |
より高い特権のアクセス許可 |
| 委任 (職場または学校のアカウント) |
Presence.ReadWrite |
注意事項なし。 |
| 委任 (個人用 Microsoft アカウント) |
サポートされていません。 |
サポートされていません。 |
| アプリケーション |
Presence.ReadWrite.All |
注意事項なし。 |
HTTP 要求
POST /users/{id}/presence/setUserPreferredPresence
| 名前 |
説明 |
| Authorization |
ベアラー {token}。 必須です。
認証と認可についての詳細をご覧ください。 |
| Content-Type |
application/json. 必須です。 |
要求本文
要求本文で、次のパラメーターを含む JSON オブジェクトを指定します。
| パラメーター |
型 |
説明 |
| availability |
string |
ベース プレゼンス情報。 |
| アクティビティ |
string |
可用性に関する補足情報。 |
| expirationDuration |
duration |
アプリ プレゼンス セッションの有効期限。 値は ISO 8601 形式で表示されます。 指定しない場合は、既定の有効期限が適用されます。 DoNotDisturb または Busy: 1 日で期限切れ その他: 7 日で有効期限が切れます |
可用性とアクティビティのサポートされる組み合わせは次のとおりです。
| availability |
アクティビティ |
Description |
| 使用可能 |
使用可能 |
ユーザーの優先プレゼンスを [使用可能] に設定します。 |
| 多忙 |
多忙 |
ユーザー優先プレゼンスを [ビジー] に設定します。 |
| DoNotDisturb |
DoNotDisturb |
ユーザー優先プレゼンスを DoNotDisturb に設定します。 |
| BeRightBack |
BeRightBack |
ユーザー優先プレゼンスを BeRightBack に設定します。 |
| 留守 |
留守 |
ユーザーの優先プレゼンスを [退席] に設定します。 |
| オフライン |
OffWork |
ユーザー優先プレゼンスを [オフライン] に設定します。 |
応答
成功した場合、このメソッドは 200 OK 応答コードを返します。
例
次の要求は、ユーザーの優先プレゼンスをユーザー fa8bf3dc-eca7-46b7-bad1-db199b62afc3の DoNotDisturb として設定し、有効期限は 8 時間にします。
要求
POST https://graph.microsoft.com/beta/users/fa8bf3dc-eca7-46b7-bad1-db199b62afc3/presence/setUserPreferredPresence
Content-Type: application/json
{
"availability": "DoNotDisturb",
"activity": "DoNotDisturb",
"expirationDuration": "PT8H"
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Users.Item.Presence.SetUserPreferredPresence;
var requestBody = new SetUserPreferredPresencePostRequestBody
{
Availability = "DoNotDisturb",
Activity = "DoNotDisturb",
ExpirationDuration = TimeSpan.Parse("PT8H"),
};
// 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.SetUserPreferredPresence.PostAsync(requestBody);
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
abstractions "github.com/microsoft/kiota-abstractions-go"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphusers "github.com/microsoftgraph/msgraph-beta-sdk-go/users"
//other-imports
)
requestBody := graphusers.NewSetUserPreferredPresencePostRequestBody()
availability := "DoNotDisturb"
requestBody.SetAvailability(&availability)
activity := "DoNotDisturb"
requestBody.SetActivity(&activity)
expirationDuration , err := abstractions.ParseISODuration("PT8H")
requestBody.SetExpirationDuration(&expirationDuration)
// 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().SetUserPreferredPresence().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.setuserpreferredpresence.SetUserPreferredPresencePostRequestBody setUserPreferredPresencePostRequestBody = new com.microsoft.graph.beta.users.item.presence.setuserpreferredpresence.SetUserPreferredPresencePostRequestBody();
setUserPreferredPresencePostRequestBody.setAvailability("DoNotDisturb");
setUserPreferredPresencePostRequestBody.setActivity("DoNotDisturb");
PeriodAndDuration expirationDuration = PeriodAndDuration.ofDuration(Duration.parse("PT8H"));
setUserPreferredPresencePostRequestBody.setExpirationDuration(expirationDuration);
graphClient.users().byUserId("{user-id}").presence().setUserPreferredPresence().post(setUserPreferredPresencePostRequestBody);
const options = {
authProvider,
};
const client = Client.init(options);
const setUserPreferredPresence = {
availability: 'DoNotDisturb',
activity: 'DoNotDisturb',
expirationDuration: 'PT8H'
};
await client.api('/users/fa8bf3dc-eca7-46b7-bad1-db199b62afc3/presence/setUserPreferredPresence')
.version('beta')
.post(setUserPreferredPresence);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Users\Item\Presence\SetUserPreferredPresence\SetUserPreferredPresencePostRequestBody;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new SetUserPreferredPresencePostRequestBody();
$requestBody->setAvailability('DoNotDisturb');
$requestBody->setActivity('DoNotDisturb');
$requestBody->setExpirationDuration(new \DateInterval('PT8H'));
$graphServiceClient->users()->byUserId('user-id')->presence()->setUserPreferredPresence()->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_user_preferred_presence.set_user_preferred_presence_post_request_body import SetUserPreferredPresencePostRequestBody
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = SetUserPreferredPresencePostRequestBody(
availability = "DoNotDisturb",
activity = "DoNotDisturb",
expiration_duration = "PT8H",
)
await graph_client.users.by_user_id('user-id').presence.set_user_preferred_presence.post(request_body)
応答
HTTP/1.1 200 OK