presence: clearPresence
本文内容
命名空间:microsoft.graph
重要
Microsoft Graph版本下的 /beta API 可能会发生更改。 不支持在生产应用程序中使用这些 API。 若要确定 API 是否在 v1.0 中可用,请使用 版本 选择器。
清除 用户的应用程序 状态会话。 如果它是用户的唯一状态会话,则成功的 clearPresence 将用户状态更改为 Offline/Offline。
阅读有关状态会话 及其退出和过期时间等内容。
权限
调用 API 需要以下权限。 若要了解详细信息,包括如何选择权限的信息,请参阅权限 。
权限类型
权限(从最低特权到最高特权)
委派(工作或学校帐户)
Presence.ReadWrite
委派(个人 Microsoft 帐户)
不支持。
应用程序
Presence.ReadWrite.All
HTTP 请求
POST /users/{userId}/presence/clearPresence
名称
说明
Authorization
Bearer {token}。必需。
Content-Type
application/json. Required.
请求正文
在请求正文中,提供具有以下参数的 JSON 对象。
参数
类型
说明
sessionId
string
应用程序状态会话的 ID。
重要
提供请求中应用程序 ID sessionId 。
响应
如果成功,此方法返回 200 OK 响应代码。
如果状态会话不存在,此方法将返回 响应 404 NotFound 代码。
示例
以下请求显示 ID 为 22553876-f5ab-4529-bffb-cfe50aa89f87 用户清除其状态会话的应用程序 fa8bf3dc-eca7-46b7-bad1-db199b62afc3。
请求
POST https://graph.microsoft.com/beta/users/fa8bf3dc-eca7-46b7-bad1-db199b62afc3/presence/clearPresence
Content-Type: application/json
{
"sessionId": "22553876-f5ab-4529-bffb-cfe50aa89f87"
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var sessionId = "22553876-f5ab-4529-bffb-cfe50aa89f87";
await graphClient.Users["{user-id}"].Presence
.ClearPresence(sessionId)
.Request()
.PostAsync();
const options = {
authProvider,
};
const client = Client.init(options);
const clearPresence = {
sessionId: '22553876-f5ab-4529-bffb-cfe50aa89f87'
};
await client.api('/users/fa8bf3dc-eca7-46b7-bad1-db199b62afc3/presence/clearPresence')
.version('beta')
.post(clearPresence);
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/beta/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/users/fa8bf3dc-eca7-46b7-bad1-db199b62afc3/presence/clearPresence"]]];
[urlRequest setHTTPMethod:@"POST"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
NSMutableDictionary *payloadDictionary = [[NSMutableDictionary alloc] init];
NSString *sessionId = @"22553876-f5ab-4529-bffb-cfe50aa89f87";
payloadDictionary[@"sessionId"] = sessionId;
NSData *data = [NSJSONSerialization dataWithJSONObject:payloadDictionary options:kNilOptions error:&error];
[urlRequest setHTTPBody:data];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
//Request Completed
}];
[meDataTask execute];
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
String sessionId = "22553876-f5ab-4529-bffb-cfe50aa89f87";
graphClient.users("fa8bf3dc-eca7-46b7-bad1-db199b62afc3").presence()
.clearPresence(PresenceClearPresenceParameterSet
.newBuilder()
.withSessionId(sessionId)
.build())
.buildRequest()
.post();
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestBody := msgraphsdk.NewSessionIdRequestBody()
sessionId := "22553876-f5ab-4529-bffb-cfe50aa89f87"
requestBody.SetSessionId(&sessionId)
userId := "user-id"
graphClient.UsersById(&userId).Presence().ClearPresence(user-id).Post(requestBody)
Import-Module Microsoft.Graph.Users.Actions
$params = @{
SessionId = "22553876-f5ab-4529-bffb-cfe50aa89f87"
}
Clear-MgUserPresence -UserId $userId -BodyParameter $params
响应
HTTP/1.1 200 OK