Share via


Microsoft Graph API developer – Using GetSchedule API to get free/busy availability information

Now you can use the GetSchedule API (when I publish this article, its available in /beta endpoint) to get the free/busy availability information for a collection of users, distributions lists, or resources, for a specified time period.

You can use it simply by calling,

POST /me/calendar/getSchedule
POST /users/{id|userPrincipalName}/calendar/getSchedule

Let me play with this API call and try to get the availability information for two users for the specified date, time, and time zone.

Request body:

{       
     "schedules": ["alex@djayasee.onmicrosoft.com", "alexw@djayasee.onMicrosoft.com"],
     "startTime": {
         "dateTime": "2018-09-26T04:00:00",
         "timeZone": "Pacific Standard Time"
     },
     "endTime": {
         "dateTime": "2018-09-27T14:00:00",
         "timeZone": "Pacific Standard Time"
     },
     "availabilityViewInterval": "15"

}

Response:

Once the above  request is successfully process, you will get 200 OK response code and get the availability info (just like the below).

{
     "@odata.context": "https://graph.microsoft.com/beta/$metadata#Collection(microsoft.graph.scheduleInformation)",
     "value": [
         {
             "scheduleId": "alex@djayasee.onmicrosoft.com",
             "availabilityView": "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002222222222222222222200000000",
             "scheduleItems": [
                 {
                     "isPrivate": false,
                     "status": "busy",
                     "subject": "Test Meeting",
                     "location": "Test Meeting",
                     "start": {
                         "dateTime": "2018-09-27T07:00:00.0000000",
                         "timeZone": "Pacific Standard Time"
                     },
                     "end": {
                         "dateTime": "2018-09-27T12:00:00.0000000",
                         "timeZone": "Pacific Standard Time"
                     }
                 }
             ],
             "workingHours": {
                 "daysOfWeek": [
                     "monday",
                     "tuesday",
                     "wednesday",
                     "thursday",
                     "friday"
                 ],
                 "startTime": "09:00:00.0000000",
                 "endTime": "17:30:00.0000000",
                 "timeZone": {
                     "@odata.type": "#microsoft.graph.customTimeZone",
                     "bias": 480,
                     "name": "Customized Time Zone",
                     "standardOffset": {
                         "time": "02:00:00.0000000",
                         "dayOccurrence": 1,
                         "dayOfWeek": "sunday",
                         "month": 11,
                         "year": 0
                     },
                     "daylightOffset": {
                         "daylightBias": -60,
                         "time": "02:00:00.0000000",
                         "dayOccurrence": 2,
                         "dayOfWeek": "sunday",
                         "month": 3,
                         "year": 0
                     }
                 }
             }
         },
         {
             "scheduleId": "alexw@djayasee.OnMicrosoft.com",
             "availabilityView": "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002222222222222222222200000000",
             "scheduleItems": [
                 {
                     "isPrivate": false,
                     "status": "busy",
                     "subject": "Test Meeting",
                     "location": "Test Meeting",
                     "start": {
                         "dateTime": "2018-09-27T07:00:00.0000000",
                         "timeZone": "Pacific Standard Time"
                     },
                     "end": {
                         "dateTime": "2018-09-27T12:00:00.0000000",
                         "timeZone": "Pacific Standard Time"
                     }
                 }
             ],
             "workingHours": {
                 "daysOfWeek": [
                     "monday",
                     "tuesday",
                     "wednesday",
                     "thursday",
                     "friday"
                 ],
                 "startTime": "09:00:00.0000000",
                 "endTime": "17:30:00.0000000",
                 "timeZone": {
                     "@odata.type": "#microsoft.graph.customTimeZone",
                     "bias": 480,
                     "name": "Customized Time Zone",
                     "standardOffset": {
                         "time": "02:00:00.0000000",
                         "dayOccurrence": 1,
                         "dayOfWeek": "sunday",
                         "month": 11,
                         "year": 0
                     },
                     "daylightOffset": {
                         "daylightBias": -60,
                         "time": "02:00:00.0000000",
                         "dayOccurrence": 2,
                         "dayOfWeek": "sunday",
                         "month": 3,
                         "year": 0
                     }
                 }
             }
         }
     ]

}

Note:
As you aware, APIs under the /beta version in Microsoft Graph are in preview and are subject to change. Use of these APIs in production applications is not supported.

Hope this helps.

Comments

  • Anonymous
    October 04, 2018
    Deva, Thanks for the API intro, sample/documentation. Its better than meetingtimes API.... Awesome Microsoft Dev!!
    • Anonymous
      October 04, 2018
      Thanks for the update. Glad the new API works as you expected :)
  • Anonymous
    October 15, 2018
    You might not know but why is this a POST for a get operation? Seems to fly in the face of https://docs.microsoft.com/en-us/azure/architecture/best-practices/api-design i.e. Organize the API around resources, Define operations in terms of HTTP methods
    • Anonymous
      October 15, 2018
      Good one Nikolai :)