Forum Discussion
PaulWins
Jun 10, 2024Copper Contributor
Book Appointment - MS Bookings Graph API
Hi, I can create appointments using the MS Bookings API, for particular staff/customers and services in my configured booking business.
However I've noticed that the API call does not stop double bookings of staff from being created (same start/end, same staff/service etc).
The MS Bookings user interface does seem to detect duplicate bookings (informing the user that they are too late as the staff member is now busy), whether the appointment is occurring at exactly the same points in time, or starts mid-way through an appointment. (I have tested this via multiple browser tabs at the booking page, booking the same appointment in each.) Inspecting the response in the web browser for the bookings UI shows an API response payload with
"error": "Status(StatusCode="FailedPrecondition", Detail="Staff not available"
Looking at https://learn.microsoft.com/en-us/graph/api/bookingbusiness-post-appointments?view=graph-rest-1.0&tabs=http for the documentation of the API I've noticed that there is very little in regards non-success responses / error codes / oDataError documentation. In fact nothing at all.
The only way around this I can see is that on booking an appointment you have to first check availability, but even that seems to be subject to a potential race condition - given that often the API call takes a few seconds to create the appointment and respond with the details.
Does anybody know of a better work-around please, or is there some documentation I am missing, seems like a really important part is missing in the book appointment API -namely it should not proceed and should return an appropriate error message/response if the staff member is not available? Or perhaps, this is by design and the app programmer does need to re-check availability ;0
Thanks in advance for any help 🙂
- jackguraeCopper Contributor
Hi, I'm currently in your place.
Did you ever figure it out?
I think the Microsoft Booking web wrap MS Bookings Graph API with another API layer which also handle an edge case when user tries to create appointment (time slot and staff) that just been booked. If so, it responses with error you described.
But for pure MS Bookings Graph API, I think it allows dev to just book the appointment ignoring availability checking?- PaulWinsCopper Contributor
Hi Jack,
Nope, just had to guard by doing another availability check before booking creation. Not bullet-proof / ideal at all as stated originally. 😒