8
votes

How do you list availability of a spacific calendar resource(Room) for a specific DateTime? Like if I want to list all Today's events for meeting Room(across all user accounts events that have booked meeting room for today), which google calendar api call can give me that? I get the Room details from Google Calendar Resource api but can't get all events booked for that room by different accounts, Appriciate it if you can help

2
Please post what you have tried so far. - Alicia
I use CalendarService to get User's Primary Calendar, and then EventsResource.ListRequest req = calservice.Events.List(primaryCalendar.Id); the problem is Events.List works with calendarId which is basically the email address, So I can only get events for that specific user(not all users).. but what I want is to get all events by RoomId, so I can see when time the room is not booked by another user, so I can book it .. I don't want to loop through all users and get their events for a DateTime and see if the event is in that room or not..I was looking for a better solution - Ella

2 Answers

6
votes

You will need to be authenticated as a user that has read-access to the room. Then you can take the resourceEmail field of the Calendar Resource API and use it as a calendarId in the events.list() Calendar API call.

2
votes

You can use freebusy API method for check if meeting room is available. Sample request:

POST https://www.googleapis.com/calendar/v3/freeBusy?fields=calendars&key={YOUR_API_KEY}

{
 "timeMin": "2018-10-18T06:30:00Z",
 "timeMax": "2018-10-18T17:00:00Z",
 "items": [
  {
   "id": "%CONFERENCE_ROOM Email ID%"
  }
 ],
 "timeZone": "GMT"
}

Sample response:

{
 "calendars": {
  "%CONFERENCE_ROOM Email ID%": {
   "busy": [
    {
     "start": "2018-10-18T07:45:00Z",
     "end": "2018-10-18T09:15:00Z"
    },
    // ...
   ]
  }
 }
}

Here you can play with Calendar API Explorer.