Set work location via API (Graph?)

Copper Contributor

Hey community!

 

The new work hours and location feature is rolling out for Outlook and Teams:

Work Hours and Location in Outlook for Efficient Collaboration (admindroid.com)

 

Does anyone know who to read and write this information (especially the location) via API / Microsoft Graph? This is a nice feature and we would like to set this programmatically.

 

Thank you very much!

 

Best regards,

 

Jens

16 Replies

@JensK2023 - Currently there is no Graph API to set/get work location and working hours via Graph API. You can suggest this feature at Microsoft Teams Feedback portal.

Thank you for the answer. We will post in Feedpack portal.

Hi @Meghana-MSFT !
How about using Graph API to get the work location? Is it supported? I mean the work location set in the calendar on outlook.

Thanks,

Screenshot 2023-06-13 at 4.07.17 PM.png

No, currently there is no such Graph API to get work location.

@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

 

2023-07-14_13-22-09.jpg

Hope this helps!

Thank you very much! We will try this!

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!

@Florian_Coviflex - We do not have any information on the availability of this API. The doc would be updated whenever the API is available. Thank you.

Thank you @Meghana-MSFT, I'll look forward to it then :lol:

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?

 

I discovered the Graph feature request https://feedbackportal.microsoft.com/feedback/idea/735c1234-0807-ee11-a81c-000d3ae5b6f4 related.

 

Likes are needed!

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. 

KevinCrouch_0-1696602855300.png

 

@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 

KevinCrouch_0-1696604542850.png

 

@Kevin Crouch thanks !

Not really scalable however, for my use-case, we'd need to use the Graph API.

I've heard this is planned to open it for work location, don't know any deadline however.

 

Please post your blog here, I'm curious anyway.

Thanks !

@JensK2023 Does anyone have any updates on this? I too am looking to get/set work locations via graph API calls. Thanks

@jackallen98 : Nope. No update at least as far as I know.