Microsoft Graph getSchedule

Updated:

The Microsoft Graph getSchedule API gets free/busy information. Like the Scheduling Assistant in Outlook, it tells you whether someone is available, not the details of their appointments. For the basics, see Get free/busy schedule of users and resources and calendar: getSchedule.

Free/busy information comes in several levels. How much information you can get depends on the permissions you have on the target user’s calendar. Let’s look at several patterns.

Test mailboxes and permissions

First, create six mailboxes for testing. User01 has the following permissions on each calendar.

User User01’s permission on the calendar
User01 (Self)
User02 None
User03 Free/busy time only
User04 Free/busy time, subject, and location
User05 Reviewer
User06 Delegate + private items

The permissions look like this in PowerShell.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
PS C:\> Get-MailboxFolderPermission User02:\Calendar | ft -AutoSize
FolderName User AccessRights SharingPermissionFlags
---------- ---- ------------ ----------------------
Calendar Default {None}
Calendar Anonymous {None}


PS C:\> Get-MailboxFolderPermission User03:\Calendar | ft -AutoSize
FolderName User AccessRights SharingPermissionFlags
---------- ---- ------------ ----------------------
Calendar Default {AvailabilityOnly}
Calendar Anonymous {None}


PS C:\> Get-MailboxFolderPermission User04:\Calendar | ft -AutoSize
FolderName User AccessRights SharingPermissionFlags
---------- ---- ------------ ----------------------
Calendar Default {AvailabilityOnly}
Calendar Anonymous {None}
Calendar User01 {LimitedDetails}


PS C:\> Get-MailboxFolderPermission User05:\Calendar | ft -AutoSize
FolderName User AccessRights SharingPermissionFlags
---------- ---- ------------ ----------------------
Calendar Default {AvailabilityOnly}
Calendar Anonymous {None}
Calendar User01 {Reviewer}


PS C:\> Get-MailboxFolderPermission User06:\Calendar | ft -AutoSize
FolderName User AccessRights SharingPermissionFlags
---------- ---- ------------ ----------------------
Calendar Default {AvailabilityOnly}
Calendar Anonymous {None}
Calendar User01 {Editor} Delegate, CanViewPrivateItems

Each user has the following appointments.

Time (Japan Standard Time) Appointment
2019/08/26 09:00 – 09:30 User01’s normal appointment
2019/08/26 09:30 – 10:00 User01’s private appointment
2019/08/27 09:00 – 09:30 User02’s normal appointment
2019/08/27 09:30 – 10:00 User02’s private appointment
2019/08/28 09:00 – 09:30 User03’s normal appointment
2019/08/28 09:30 – 10:00 User03’s private appointment
2019/08/29 09:00 – 09:30 User04’s normal appointment
2019/08/29 09:30 – 10:00 User04’s private appointment
2019/08/30 09:00 – 09:30 User05’s normal appointment
2019/08/30 09:30 – 10:00 User05’s private appointment
2019/09/02 09:00 – 09:30 User06’s normal appointment
2019/09/02 09:30 – 10:00 User06’s private appointment

Get free/busy information with getSchedule

Let’s use getSchedule to get each user’s free/busy information. To see the effect of the calendar permissions, this example uses User01’s delegated access token. If you do not know how to try Microsoft Graph, see “Try delegated permissions with Office365APIEditor (built-in application)” in Getting started with Microsoft Graph. Send the following request.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
POST https://graph.microsoft.com/v1.0/me/calendar/getSchedule
Prefer : outlook.timezone="Tokyo Standard Time"

{
"schedules": [
"User01@contoso.com",
"User02@contoso.com",
"User03@contoso.com",
"User04@contoso.com",
"User05@contoso.com",
"User06@contoso.com"],
"startTime": {
"dateTime": "2019-08-26T09:00:00",
"timeZone": "Tokyo Standard Time"
},
"endTime": {
"dateTime": "2019-09-02T18:00:00",
"timeZone": "Tokyo Standard Time"
},
"availabilityViewInterval": 30
}

You get a response like the following.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#Collection(microsoft.graph.scheduleInformation)",
"value": [
{
"scheduleId": "User01@contoso.com",
"availabilityView": "220000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"scheduleItems": [
{
"isPrivate": false,
"status": "busy",
"subject": "User01 Normal",
"location": "Harry's Bar",
"start": {
"dateTime": "2019-08-26T09:00:00",
"timeZone": "Tokyo Standard Time"
},
"end": {
"dateTime": "2019-08-26T09:30:00",
"timeZone": "Tokyo Standard Time"
}
},
{
"isPrivate": true,
"status": "busy",
"subject": "User01 Private",
"location": "Harry's Bar",
"start": {
"dateTime": "2019-08-26T09:30:00",
"timeZone": "Tokyo Standard Time"
},
"end": {
"dateTime": "2019-08-26T10:00:00",
"timeZone": "Tokyo Standard Time"
}
}
],
"workingHours": {
"daysOfWeek": [
"monday",
"tuesday",
"wednesday",
"thursday",
"friday"
],
"startTime": "08:00:00.0000000",
"endTime": "17:00:00.0000000",
"timeZone": {
"name": "Tokyo Standard Time"
}
}
},
{
"scheduleId": "User02@contoso.com",
"error": {
"message": "Microsoft.Exchange.InfoWorker.Common.Availability.NoFreeBusyAccessException: The caller does not have access to free/busy data.\r\n. Name of the server where exception originated: TY1PR01MB1692. LID: 44348",
"responseCode": "ErrorNoFreeBusyAccess"
}
},
{
"scheduleId": "User03@contoso.com",
"availabilityView": "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000220000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"scheduleItems": [
{
"status": "busy",
"start": {
"dateTime": "2019-08-28T09:00:00",
"timeZone": "Tokyo Standard Time"
},
"end": {
"dateTime": "2019-08-28T09:30:00",
"timeZone": "Tokyo Standard Time"
}
},
{
"status": "busy",
"start": {
"dateTime": "2019-08-28T09:30:00",
"timeZone": "Tokyo Standard Time"
},
"end": {
"dateTime": "2019-08-28T10:00:00",
"timeZone": "Tokyo Standard Time"
}
}
],
"workingHours": {
"daysOfWeek": [
"monday",
"tuesday",
"wednesday",
"thursday",
"friday"
],
"startTime": "08:00:00.0000000",
"endTime": "17:00:00.0000000",
"timeZone": {
"@odata.type": "#microsoft.graph.customTimeZone",
"bias": -540,
"name": "Customized Time Zone",
"standardOffset": {
"time": "00:00:00.0000000",
"dayOccurrence": 0,
"dayOfWeek": "sunday",
"month": 0,
"year": 0
},
"daylightOffset": {
"daylightBias": 0,
"time": "00:00:00.0000000",
"dayOccurrence": 0,
"dayOfWeek": "sunday",
"month": 0,
"year": 0
}
}
}
},
{
"scheduleId": "User04@contoso.com",
"availabilityView": "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000220000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"scheduleItems": [
{
"isPrivate": false,
"status": "busy",
"subject": "User04 Normal",
"location": "Harry's Bar",
"start": {
"dateTime": "2019-08-29T09:00:00",
"timeZone": "Tokyo Standard Time"
},
"end": {
"dateTime": "2019-08-29T09:30:00",
"timeZone": "Tokyo Standard Time"
}
},
{
"isPrivate": true,
"status": "busy",
"subject": "Private Appointment",
"location": "",
"start": {
"dateTime": "2019-08-29T09:30:00",
"timeZone": "Tokyo Standard Time"
},
"end": {
"dateTime": "2019-08-29T10:00:00",
"timeZone": "Tokyo Standard Time"
}
}
],
"workingHours": {
"daysOfWeek": [
"monday",
"tuesday",
"wednesday",
"thursday",
"friday"
],
"startTime": "08:00:00.0000000",
"endTime": "17:00:00.0000000",
"timeZone": {
"@odata.type": "#microsoft.graph.customTimeZone",
"bias": -540,
"name": "Customized Time Zone",
"standardOffset": {
"time": "00:00:00.0000000",
"dayOccurrence": 0,
"dayOfWeek": "sunday",
"month": 0,
"year": 0
},
"daylightOffset": {
"daylightBias": 0,
"time": "00:00:00.0000000",
"dayOccurrence": 0,
"dayOfWeek": "sunday",
"month": 0,
"year": 0
}
}
}
},
{
"scheduleId": "User05@contoso.com",
"availabilityView": "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000220000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"scheduleItems": [
{
"isPrivate": false,
"status": "busy",
"subject": "User05 Normal",
"location": "Harry's Bar",
"start": {
"dateTime": "2019-08-30T09:00:00",
"timeZone": "Tokyo Standard Time"
},
"end": {
"dateTime": "2019-08-30T09:30:00",
"timeZone": "Tokyo Standard Time"
}
},
{
"isPrivate": true,
"status": "busy",
"subject": "Private Appointment",
"location": "",
"start": {
"dateTime": "2019-08-30T09:30:00",
"timeZone": "Tokyo Standard Time"
},
"end": {
"dateTime": "2019-08-30T10:00:00",
"timeZone": "Tokyo Standard Time"
}
}
],
"workingHours": {
"daysOfWeek": [
"monday",
"tuesday",
"wednesday",
"thursday",
"friday"
],
"startTime": "08:00:00.0000000",
"endTime": "17:00:00.0000000",
"timeZone": {
"@odata.type": "#microsoft.graph.customTimeZone",
"bias": -540,
"name": "Customized Time Zone",
"standardOffset": {
"time": "00:00:00.0000000",
"dayOccurrence": 0,
"dayOfWeek": "sunday",
"month": 0,
"year": 0
},
"daylightOffset": {
"daylightBias": 0,
"time": "00:00:00.0000000",
"dayOccurrence": 0,
"dayOfWeek": "sunday",
"month": 0,
"year": 0
}
}
}
},
{
"scheduleId": "User06@contoso.com",
"availabilityView": "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000220000000000000000",
"scheduleItems": [
{
"isPrivate": false,
"status": "busy",
"subject": "User06 Normal",
"location": "Harry's Bar",
"start": {
"dateTime": "2019-09-02T09:00:00",
"timeZone": "Tokyo Standard Time"
},
"end": {
"dateTime": "2019-09-02T09:30:00",
"timeZone": "Tokyo Standard Time"
}
},
{
"isPrivate": true,
"status": "busy",
"subject": "Private Appointment",
"location": "",
"start": {
"dateTime": "2019-09-02T09:30:00",
"timeZone": "Tokyo Standard Time"
},
"end": {
"dateTime": "2019-09-02T10:00:00",
"timeZone": "Tokyo Standard Time"
}
}
],
"workingHours": {
"daysOfWeek": [
"monday",
"tuesday",
"wednesday",
"thursday",
"friday"
],
"startTime": "08:00:00.0000000",
"endTime": "17:00:00.0000000",
"timeZone": {
"@odata.type": "#microsoft.graph.customTimeZone",
"bias": -540,
"name": "Customized Time Zone",
"standardOffset": {
"time": "00:00:00.0000000",
"dayOccurrence": 0,
"dayOfWeek": "sunday",
"month": 0,
"year": 0
},
"daylightOffset": {
"daylightBias": 0,
"time": "00:00:00.0000000",
"dayOccurrence": 0,
"dayOfWeek": "sunday",
"month": 0,
"year": 0
}
}
}
}
]
}

As you can see, the free/busy information is basically returned according to the permissions. You can also see that the permission to view private items has no effect when you get free/busy information with getSchedule.

Advertisement