Share via

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 Security | Microsoft Graph
0 comments No comments

1 answer

Sort by: Most helpful
  1. Bhanu Kiran 3,616 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": ["******@contoso.onmicrosoft.com", "******@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".

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.