Unable to set presence message via Set-MgUserPresenceStatusMessage

Rajen Jani 20 Reputation points
2023-01-22T16:40:55.5266667+00:00

I am trying to set a custom status message for a Teams enabled user in my developer tenant. This test user has an E5 Developer license assigned against it.

I am following the API documentation mentioned here.

To set this up I do the following:

Connect-MgGraph -TenantId "<Tenant ID>" -UseDeviceAuthentication -Scopes "User.Read.All","User.ReadWrite.All","Presence.ReadWrite"

Select-MgProfile -Name "beta"
Import-Module Microsoft.Graph.Users.Actions
#
$params = @{
	StatusMessage = @{
		Message = @{
			Content = "Hey I am available now"
			ContentType = "text"
		}
	}
}

Set-MgUserPresenceStatusMessage -UserId $userId -BodyParameter $params -Verbose

When I run this I get the following message:

VERBOSE: Performing the operation "Set-MgUserPresenceStatusMessageSet" on target "Call remote '*
UsersPresenceSetStatusMessage' operation".
Set-MgUserPresenceStatusMessageSet: Cannot set the presence of another user. Authenticated user
: 530c5b87-8699-445a-91ba-d60dbebbe2a8. Requested user: mytest*user@testdomain.onmicrosoft.com

My expectation is that this would set the status message for the user so it is visible in Teams when someone tries to send a message to this id.

Here are some other details that may help:

PowerShell Version : 7.3.1

Microsoft.Graph version: 2.0.0-preview3
OS: Fedora Linux 37

I have not set up any app based registrations for this task. I am not sure whether I am supposed to as I do consent to the required permissions.

Appreciate any help you can provide me on this.

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,515 questions
0 comments No comments
{count} votes

Accepted answer
  1. Shivam Dhiman 5,946 Reputation points
    2023-01-26T00:35:46.04+00:00

    Hi @Rajen Jani

    As per my testing setStatusMessage Graph API can only change the status message of the signed-In user using delegated permission only.
    Currently, this API does not support application permission as provided in the documentation.

    This API gives the error “Cannot set the presence of another user. Authenticated user: 27afc846-ccb1-4a66-xxxxxxxx. Requested user: xxxxxx-xx-x-x-xxxxxx” when the signed in user is different than user you are trying to set the status. If you want to change the status of a particular user, you need to be signed in as that user.
    Please note: APIs under the /beta version in Microsoft Graph are subject to change. Use of these APIs in production applications is not supported.

    Hope this helps.

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

    0 comments No comments

0 additional answers

Sort by: Most helpful