Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ErrorItemNotFound when trying to retrieve room calendar via MS Graph API

Next to retrieving calendar views of a user's calendar (on behalf of the user), we are trying hard to also get the calendar view of rooms via the Graph API using https://graph.microsoft.com/beta/users/[email protected]/calendarView. It's a painful process since we've been running into many problems and are currently stuck with the following 404 response:

https://graph.microsoft.com:443/v1.0/users/[email protected]/calendarView?startDateTime=2018-12-04T23:00:00.000Z&endDateTime=2019-02-10T22:59:59.999Z

{
  "error": {
    "code": "ErrorItemNotFound",
    "message": "The specified object was not found in the store.",
    "innerError": {
      "request-id": "358a003a-57a4-4f0e-91da-edc17c1fa2d8",
      "date": "2018-12-12T07:38:33"
    }
  }
}

The email address of the room has been double checked and the resource exists, since we can create appointments with it and it is even being returned in the response when we retrieve the calendar of the user who has an appointment in that location.

App permissions and OAuth2 scopes are set to: openid email profile offline_access https://graph.microsoft.com/Calendars.Read https://graph.microsoft.com/Calendars.Read.Shared https://graph.microsoft.com/User.Read https://graph.microsoft.com/User.ReadBasic.All https://graph.microsoft.com/User.Read.All, so that should not be an issue, judging by the documentation.

Does anyone know how to solve this?

like image 893
Pascal Lindelauf Avatar asked Dec 12 '18 09:12

Pascal Lindelauf


People also ask

How do I get calendar events in graph API?

Take Application permission: Calendars. And then use Get access without a user to get the access token. After getting the access token, call the calendar events endpoint. The format of the value of Authorization is "Bearer {access_token from the last step}".

What is Microsoft Graph API permissions?

Allows the app to manage permission grants for application permissions to any API (including Microsoft Graph) and application assignments for any app, on behalf of the signed-in user. Allows the app to manage delegated permission grants for any API (including Microsoft Graph), on behalf of the signed-in user.


2 Answers

I've tried all possible ways, but there is no way to get access. This is what I've tried out the following in the Graph explorer:

  • https://graph.microsoft.com/v1.0/users/[email protected]/events -> DelegatedCalendarAccessDenied
  • https://graph.microsoft.com/v1.0/users/[email protected]/calendarView?startDateTime=2019-01-14&endDateTime=2019-01-18 -> ErrorItemNotFound
  • https://graph.microsoft.com/v1.0/users/[email protected]/calendar/calendarView?startDateTime=2019-01-14&endDateTime=2019-01-18 -> ErrorItemNotFound

All three on both the v1.0 and the beta.

It isn't an issue with rights, because for my testing I granted the Graph Explorer the Directory.ReadWrite.All scope. Resulting in the following scp claim. scope screenshot

The first requests seems the most promising (because of the different error), I also made myself a delegate with full control of the rooms-mailbox. That still didn't help.

A request to https://graph.microsoft.com/v1.0/users/[email protected] gives a result, as in a result describing the meetingroom.

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users/$entity",
    "businessPhones": [],
    "displayName": "Meeting room 1",
    "givenName": null,
    "jobTitle": null,
    "mail": "[email protected]",
    "mobilePhone": null,
    "officeLocation": null,
    "preferredLanguage": null,
    "surname": null,
    "userPrincipalName": "[email protected]",
    "id": "3e0a7b7e-xxxx-xxxx-xxxx-xxxxcxxxx120"
}

After doing all these tests, I can only conclude that you cannot access the events in a rooms mailbox. This is either intended (as in only use the scheduling assistant) or a bug.

Maybe some of the Microsoft guys around here could clarify this?

like image 156
Stephan Avatar answered Oct 27 '22 10:10

Stephan


FINALLY! After going through this with countless Microsoft support people, each of whom said this was not their territory and did not know where to forward the question, I got in touch with somebody from the Exchange team. He suggested the one thing that worked for us: the user on behalf of which you are retrieving the room resource calendar needs to be a delegate of that room resource!

In addition, to retrieve the list of room resources which the user can select from, we needed to use the findRooms endpoint but this only works on the beta API. The only drawback of this is that you cannot seem to filter for rooms of which the user is a delegate. So the user will get a list of rooms for which he might or might not be able to retrieve the calendar.

A final drawback of the room resource calendarView response is that the response does not contain the names of the meetings planned in the rooms. The description of each event only contains the name of the meeting organizer.

like image 3
Pascal Lindelauf Avatar answered Oct 27 '22 09:10

Pascal Lindelauf