1

Update Attendees of an Event

by
Published Jul 26, 2022
Script gcal Verified

The script

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

3
type Gcal = {
4
  token: string;
5
};
6
export async function main(
7
  gcal_auth: Gcal,
8
  calendarId: string,
9
  eventId: string,
10
  attendees: Array<object>,
11
) {
12
  const alwaysIncludeEmail = true;
13
  const sendUpdates = "all";
14
  const supportsAttachments = true;
15
  const UPDATE_EVENT_ATTENDEES_URL = `https://www.googleapis.com/calendar/v3/calendars/${calendarId}/events/${eventId}/?alwaysIncludeEmail=${alwaysIncludeEmail}&sendUpdates=${sendUpdates}&supportsAttachments=${supportsAttachments}`;
16

17
  const token = gcal_auth["token"];
18

19
  const body = {
20
    attendees: attendees,
21
  };
22

23
  const response = await fetch(UPDATE_EVENT_ATTENDEES_URL, {
24
    method: "PUT",
25
    body: JSON.stringify(body),
26
    headers: {
27
      Authorization: "Bearer " + token,
28
      "Content-Type": "application/json",
29
    },
30
  });
31

32
  const result = await response.json();
33

34
  return result;
35
}
36

Other submissions
  • Submitted by rossmccrann Deno
    Created 399 days ago
    1
    type Gcal = {
    2
      token: string;
    3
    };
    4
    export async function main(
    5
      gcal_auth: Gcal,
    6
      calendarId: string,
    7
      eventId: string,
    8
      attendees: Array<object>,
    9
    ) {
    10
      const alwaysIncludeEmail = true;
    11
      const sendUpdates = "all";
    12
      const supportsAttachments = true;
    13
      const UPDATE_EVENT_ATTENDEES_URL = `https://www.googleapis.com/calendar/v3/calendars/${calendarId}/events/${eventId}/?alwaysIncludeEmail=${alwaysIncludeEmail}&sendUpdates=${sendUpdates}&supportsAttachments=${supportsAttachments}`;
    14
    
    
    15
      const token = gcal_auth["token"];
    16
    
    
    17
      const body = {
    18
        attendees: attendees,
    19
      };
    20
    
    
    21
      const response = await fetch(UPDATE_EVENT_ATTENDEES_URL, {
    22
        method: "PUT",
    23
        body: JSON.stringify(body),
    24
        headers: {
    25
          Authorization: "Bearer " + token,
    26
          "Content-Type": "application/json",
    27
        },
    28
      });
    29
    
    
    30
      const result = await response.json();
    31
    
    
    32
      return result;
    33
    }
    34