Forum Discussion

JensK2023's avatar
JensK2023
Copper Contributor
Jun 05, 2023

Set work location via API (Graph?)

Hey community!

 

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

https://blog.admindroid.com/work-hours-and-location-in-outlook-for-efficient-collaboration/

 

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

21 Replies

  • md5hash's avatar
    md5hash
    Copper Contributor

    Hey folks - we'd love to use this feature to replace a script setup we have in place in teams, which is a Microsoft List a coworker set up that has staff names printed in it, and each staff person manually goes in (about 6-8 clicks) to the pinned "working from" tab in our General channel, finds their name (or anyone else's name; there's no security on this) and then has the option to click Not Working Today, Remote, or Office. Then every morning at 4AM then List gets reset back to default.

    Using the location system defined here is much, much easier for a user to set with just 2 clicks. But on the other hand, what's NOT simple to do, is see your entire set of coworkers' statuses on a page like our current List does. What we need is this API to have the ability to read other people's statuses, not just our own (from the post down in February 2026). Then we could make an output file that reads /v1/me/workLocation (probably wouldn't be "me" in this case) .... user1, user2, user3, etc and then outputs all this into a single pane of information.

    We can't be the only org looking for a way to get a single viewscreen that has a list of users and their Teams Presence statuses in it. Our "List" works fine, it's just a lot of clicks to reach the page and set our statuses.

  • jackallen98's avatar
    jackallen98
    Copper Contributor

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

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

     

    Likes are needed!

  • 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!

    • JensK2023's avatar
      JensK2023
      Copper 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_Crouch's avatar
        Kevin_Crouch
        Brass 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. 

         

    • JensK2023's avatar
      JensK2023
      Copper Contributor
      Thank you very much! We will try this!
      • Florian_Coviflex's avatar
        Florian_Coviflex
        Copper 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!

    • RipplingGraphAPI's avatar
      RipplingGraphAPI
      Copper Contributor

      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,

      • Meghana-MSFT's avatar
        Meghana-MSFT
        Former Employee
        No, currently there is no such Graph API to get work location.
    • JensK2023's avatar
      JensK2023
      Copper Contributor
      Thank you for the answer. We will post in Feedpack portal.
      • uername465's avatar
        uername465
        Brass Contributor

        upvote this feature
        https://feedbackportal.microsoft.com/feedback/idea/f4ed696b-9971-ef11-a4e7-6045bdb238dc