"Cannot set the presence of another user" by using the Presence GraphAPI - changing the presence of another user

Luca Bergmann 0 Reputation points
2024-04-07T12:47:33.8866667+00:00

Describe the bug By using the grapAPI with the presence statusmessage function, i get the following error: "Cannot set the presence of another user... Status: 401 Unauthorized"

I tried this with the graphapi over https://developer.microsoft.com/en-us/graph/graph-explorer and with the Microsoft.Graph.Users.Actions Powershell Module.

For both with my admin user that has the required consensts . (Presence.ReadWrite)

To Reproduce in Powershell `Import-Module ActiveDirectory Import-Module Microsoft.Graph.Authentication Import-Module Microsoft.Graph.Users Connect-MgGraph Presence.ReadWrite

$params = @{ statusMessage = @{ message = @{ content = "Hey, this is a test" contentType = "text" } expiryDateTime = @{ dateTime = "2024-04-02T20:05:33.2079781" timezone = "Europe/Berlin" } } } Set-MgUserPresenceStatusMessage -UserId "UserID" -BodyParameter $params Disconnect-MgGraph`

To Reproduce in the graphAPI url: https://graph.microsoft.com/v1.0/users/[UserID]/presence/setStatusMessage Body: { "statusMessage": { "message": { "content": "Hey, this is a test", "contentType": "text" } } }

Expected behavior Chaning the statusmsg in teams

Screenshots image

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,994 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,500 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Rich Matheisen 46,636 Reputation points
    2024-04-07T18:37:19.49+00:00

    Has your user been delegated the authority to change the status of the other user?

    https://learn.microsoft.com/en-us/answers/questions/1163128/unable-to-set-presence-message-via-set-mguserprese

    I don't think it's really a PowerShell problem, though.


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.