Edits history of script submission #23337 for ' Get Event (outlook)'

  • bunnative
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    
    /**
     * Get Event
     * Get one calendar event by id, with start and end times expressed in `time_zone`. Requires Calendars.Read (covered by the default Calendars.ReadWrite).
     */
    export async function main(
      auth: RT.Outlook,
      event_id: string,
      select: string | undefined,
      time_zone: string = "UTC"
    ) {
      const url = new URL(
        `https://graph.microsoft.com/v1.0/me/events/${encodeURIComponent(event_id)}`
      )
      if (select != null && select !== "") {
        url.searchParams.append("$select", select)
      }
    
      const response = await fetch(url, {
        headers: {
          Authorization: `Bearer ${auth.token}`,
          Accept: "application/json",
          Prefer: `outlook.timezone="${time_zone}"`,
        },
      })
    
      if (!response.ok) {
        throw new Error(`${response.status} ${await response.text()}`)
      }
    
      return await response.json()
    }
    

    Submitted by hugo989 6 hours ago

  • bunnative
    //native
    
    /**
     * Get Event
     * Get one calendar event by id, with start and end times expressed in `time_zone`. Requires Calendars.Read on the connection.
     */
    export async function main(
      auth: RT.Outlook,
      event_id: string,
      select: string | undefined,
      time_zone: string = "UTC"
    ) {
      const url = new URL(
        `https://graph.microsoft.com/v1.0/me/events/${encodeURIComponent(event_id)}`
      )
      if (select != null && select !== "") {
        url.searchParams.append("$select", select)
      }
    
      const response = await fetch(url, {
        headers: {
          Authorization: `Bearer ${auth.token}`,
          Accept: "application/json",
          Prefer: `outlook.timezone="${time_zone}"`,
        },
      })
    
      if (!response.ok) {
        throw new Error(`${response.status} ${await response.text()}`)
      }
    
      return await response.json()
    }
    

    Submitted by hugo989 6 hours ago