How to use API SetPressence to Microsoft Teams

TEO JUN JIA 5 Reputation points
2023-01-21T03:13:16.3466667+00:00

I wish to use the API to setPressence to my Microsoft Teams account, but I can't find my userID and sessionID. [https://learn.microsoft.com/en-us/graph/api/presence-setpresence?view=graph-rest-beta&tabs=http Where should I get the userID and sessionID of my account?

Microsoft Security Microsoft Graph
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Dillon Silzer 57,826 Reputation points Volunteer Moderator
    2023-01-21T03:34:37.49+00:00

    Hello,

    To get the userID send an HTTP GET response to Graph API:

    GET /me

    Example response: "id": "87d349ed-44d7-43e1-9a83-5f2406dee5bd"

    Get user (documentation)

    https://learn.microsoft.com/en-us/graph/api/user-get?view=graph-rest-1.0&tabs=http

    On the other hand, the Application itself also has an ID (called sessionID). You will want to open the application you are trying to use and find its ID (looks similar to the userID). The Application ID can be found in the Azure AD Portal.


    If this is helpful please accept answer.


  2. Gopinath Chennamadhavuni 2,446 Reputation points
    2023-01-23T06:14:32.9033333+00:00

    Hi @TEO JUN JIA ,

    Hope you are doing well.

    To get User ID, please execute the Graph API: GET me/ or GET users/{User-ID}

    My-ID

    According to this documentation we have to give ID of the application as the sessionID to set an application's presence session for a user.

    180224-id.png

    I tried it in postman tool by using the clientID of the azure app configured to be used in postman for authentication.

    Please find the below screenshot

    Set-Pres

    Please refer these links to set:

    An application's presence session for a user: [https://learn.microsoft.com/en-us/graph/api/presence-setpresence?view=graph-rest-1.0

    Set the preferred availability and activity status for a user: [https://learn.microsoft.com/en-us/graph/api/presence-setuserpreferredpresence?view=graph-rest-1.0

    My_own_pre

    If the answer is helpful, please click Accept Answer and kindly upvote it. If you have any further questions about this answer, please click Comment.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.