Bewerken

Delen via


presence: setStatusMessage

Namespace: microsoft.graph

Set a presence status message for a user. An optional expiration date and time can be supplied.

This API is available in the following national cloud deployments.

Global service US Government L4 US Government L5 (DOD) China operated by 21Vianet

Permissions

Choose the permission or permissions marked as least privileged for this API. Use a higher privileged permission or permissions only if your app requires it. For details about delegated and application permissions, see Permission types. To learn more about these permissions, see the permissions reference.

Permission type Least privileged permissions Higher privileged permissions
Delegated (work or school account) Presence.ReadWrite Not available.
Delegated (personal Microsoft account) Not supported. Not supported.
Application Presence.ReadWrite.All Not available.

HTTP Request

POST /users/{userId}/presence/setStatusMessage

Request headers

Name Description
Authorization Bearer {token}. Required. Learn more about authentication and authorization.
Content-Type application/json. Required.

Request body

In the request body, provide a JSON object with the following parameters.

Parameter Type Description
statusMessage microsoft.graph.presenceStatusMessage Contains the presence status message of the user.

Response

If successful, this method returns a 200 OK response code.

Examples

Example 1: Set status message with expiry date

The following request sets the presence status message as "Hey I'm currently in a meeting." for user fa8bf3dc-eca7-46b7-bad1-db199b62afc3, with the expiration on 2022-10-18 at 17:05:33.2079781 Pacific Standard Time.

Request

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"
    }
  }
}

Response

HTTP/1.1 200 OK

Example 2: Set status message of another user

The following request sets the presence status message as "Hey I am available now" for user fa8bf3dc-eca7-46b7-bad1-db199b62afc3. In Example 3, presence information for user fa8bf3dc-eca7-46b7-bad1-db199b62afc3 is obtained on behalf of another user via a getPresence request.

Request

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"
    }
  }
}

Response

HTTP/1.1 200 OK

Example 3: Get another user presence

This example follows Example 2. Presence information for user fa8bf3dc-eca7-46b7-bad1-db199b62afc3 is obtained on behalf of another user via a getPresence request.

Request

GET https://graph.microsoft.com/v1.0/users/fa8bf3dc-eca7-46b7-bad1-db199b62afc3/presence

Response

Because this request gets the presence status for another user, the statusMessage.expiryDateTime and statusMessage.publishedDateTime properties are not included in the response body.

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"
    }
  }
}