How to prevent double booking of events in a Microsoft Graph API meeting room calendar?

Cedric Vinci 0 Reputation points
2023-04-11T15:36:25.63+00:00

I am using Microsoft Graph API to create events in a meeting room calendar, and I have set the 'allowNewTimeProposals' tag to false, the 'showAs' tag to busy, and the 'isAllDay' tag to false. However, I have noticed that I am still able to create multiple events at the same time slot without receiving any error message from the API. This results in conflicts and double bookings. Is there a way to ensure that the API returns an error if a time slot is already occupied by another event in the calendar? (all of that in one API Call)

POST https://graph.microsoft.com/v1.0/users/<UserId>/calendars/<calendarID>/events 
Authorization: Bearer {{token}}
Content-type: application/json 

Body Request:

{
  "subject": "ONE PUNCH MAN PT7",
  "body": {
    "contentType": "HTML",
    "content": "1000 pull-ups?"
  },
  "start": {
    "dateTime": "2023-04-11T18:05:00",
    "timeZone": "Romance Standard Time"
  },
  "end": {
    "dateTime": "2023-04-11T18:15:00",
    "timeZone": "Romance Standard Time"
  },
  "location": {
    "displayName": "<MeetingRoomName>",
    "locationUri": "<MeetingRoomName>@<organizationName>.io",
    "locationType": "conferenceRoom",
    "uniqueId": "<MeetingRoomName>@<organizationName>.io",
    "uniqueIdType": "directory",
  },
  "attendees": [
    {
      "emailAddress": {
      "address":"<MeetingRoomName>@<organizationName>.io",
      "name": "<MeetingRoomName>"
      },
      "type": "resource"
  }
  ],
  "organizer": {
        "emailAddress": {
          "name": "<MeetingRoomName>",
          "address": "<MeetingRoomName>@<organizationName>.io"
        }
  },
  "allowNewTimeProposals": false,
  "showAs": "busy",
  "isAllDay": false,
}
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,857 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Bhanu Kiran 3,526 Reputation points
    2023-04-11T22:09:21.51+00:00

    Hi @Cedric Vinci ,

    Outlook client/web allows double booking i.e., allows to book/create event more than 1 appointment with same participants at same time, and while booking it will show the availability of the participants as tentative/unavailable but still allows to send invite.

    You can however use calendar-getschedule to know free/busy availability information for a collection of users, distributions lists, or resources (rooms or equipment) for a specified time period.

    POST https://graph.microsoft.com/v1.0/me/calendar/getSchedule   
    Prefer: outlook.timezone="Pacific Standard Time"  
    Content-Type: application/json  
      
    {          
        "schedules": ["adelev@contoso.onmicrosoft.com", "meganb@contoso.onmicrosoft.com"],  
        "startTime": {  
            "dateTime": "2019-03-15T09:00:00",  
            "timeZone": "Pacific Standard Time"  
        },  
        "endTime": {  
            "dateTime": "2019-03-15T18:00:00",  
            "timeZone": "Pacific Standard Time"  
        },  
        "availabilityViewInterval": 60  
    }
    

    Additional references findmeetingtimes.

    Hope this helps,

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have further questions about this answer, please click "Comment".

    0 comments No comments