0

Delete Calendar Event

by
Published today

Delete an event, or one occurrence of a recurring event when given an occurrence id from List Event Instances. If you are the organizer, attendees get a cancellation. Requires Calendars.ReadWrite (a connection default).

Script ms_outlook Verified

The script

Submitted by hugo989 Typescript (fetch-only)
Verified 2 hours ago
1
//native
2

3
/**
4
 * Delete Calendar Event
5
 * Delete an event, or one occurrence of a recurring event when given an occurrence id from List Event Instances. If you are the organizer, attendees get a cancellation. Requires Calendars.ReadWrite (a connection default).
6
 */
7
export async function main(auth: RT.MsOutlook, event_id: string) {
8
  const response = await fetch(
9
    `https://graph.microsoft.com/v1.0/me/events/${encodeURIComponent(event_id)}`,
10
    {
11
      method: "DELETE",
12
      headers: {
13
        Authorization: `Bearer ${auth.token}`,
14
        Accept: "application/json",
15
      },
16
    }
17
  )
18

19
  if (!response.ok) {
20
    throw new Error(`${response.status} ${await response.text()}`)
21
  }
22

23
  // 204 No Content
24
  return { success: true }
25
}
26