Prevent conflicts when creating events in a resource calendar using Google Calendar V3

Viewed 549

I'm trying to solve a problem of preventing double bookings using the Google Calendar Api (v3). I'm using Google resources in a GSuite environment. The bookings are made from a centralized platform on behalf of multiple users and are applied to multiple rooms (resources). The responsible application authenticates using a Service Account. The resource calendars are all configured to only accept invitations that do not conflict.

So far I found out that there are at least two ways to book a resource:

  1. Create an event in the resource calendar
  2. Create an event in a personal calendar en add the resource as attendee

I found out that in the first senario, events can be added to the resource calendar, even if they cause a conflict. There is no failure in the api response, the event is just added.

I tested the second scenario with my personal calendar and found out that the room needs to respond to the event invitation. Apparently that process may take several minutes before the room responds.

I'm building an api that should respond as fast as possible, but I want it to only create an event if it doesn't conflict. Of course I can use the free/busy information to reduce the chance of conclicts, but I would like to eliminate that chance entirely.

Does anyone know if Google provides functionality for this problem out of the box?

Thanks in advance.

1 Answers

Google does not do any validation on the api. You send what you want inserted and they insert it. Its up to you to ensure that it does not conflict with anything already there.

May i suggest that you check before you insert it and then do a double check in a few minutes to ensure there is no conflicts if there is then delete it again.

Related