Forum Discussion
Set work location via API (Graph?)
JensK2023 you're capable of hitting this particular endpoint just fine.
address: "https://presence.teams.microsoft.com"
uri: /v1/me/workLocation
body:
{
"location": "@{variables('vStatus')}",
"expiration": "@{formatDateTime(body('Current_time'), 'yyyy-MM-ddT22:00:00.0Z')}"
}
"0" clears your status
"1" is in office
"2" is remote
Hope this helps!
- JensK2023Jul 27, 2023Copper Contributor
I try to rebuild this, but I am not authorized. We try to hand over an access token. What scopes do I need for setting this work location?
- Kevin_CrouchOct 06, 2023Brass Contributor
I have this working with the Body they mentioned above.
The time portion for formatDateTime comes from adding the "Current Time" action earlier in the flow.
And the SharePoint is just the "Send an HTTP Request to SharePoint" item.
Rather than making you manually deal with the access tokens, this offloads the Access Tokens to the SharePoint Connection.The Manually triggering the flow is just for Demo purposes, of course.
I'm hoping to try and make something that will look for my location at, say, 8am and if it is still my home set my location to "Working Remotely" but if I am at the Office, set it to "Office"
Unfortunately, it doesn't look like there is support for custom locations listed, or it might be useful that it could even show things like "At Client X" - but I suppose that could potentially just go in the Custom Status field instead.
- JensK2023Jul 16, 2023Copper ContributorThank you very much! We will try this!
- Florian_CoviflexJul 24, 2023Copper Contributor
Do you know when the possibility of doing this via API will be opened up? In order to synchronize these workLocations with another internal tool? Meghana-MSFT
Thank you!- Kevin_CrouchOct 06, 2023Brass Contributor
Florian_Coviflex I found you can get the prescence status from /v1/presence/getpresence/ and a body payload like [{"mri":"8:orgid:$UserObjectID"}]
I am just Parsing the response JSON with a quick and dirty sample Schema, but it worked quite well in quick testing. you can also query multiple at once!
I will try to work on a blog post about it