Edits history of script submission #23340 for ' Get Free/Busy Schedule (outlook)'

  • bunnative
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    
    /**
     * Get Free/Busy Schedule
     * Get the free/busy availability of users, distribution lists or rooms (by email address) over a window of local times in `time_zone`. Requires Calendars.Read (covered by the default Calendars.ReadWrite).
     */
    export async function main(
      auth: RT.Outlook,
      schedules: string[],
      start: string,
      end: string,
      time_zone: string = "UTC",
      availability_view_interval: number = 30
    ) {
      const response = await fetch(
        "https://graph.microsoft.com/v1.0/me/calendar/getSchedule",
        {
          method: "POST",
          headers: {
            Authorization: `Bearer ${auth.token}`,
            "Content-Type": "application/json",
            Accept: "application/json",
            Prefer: `outlook.timezone="${time_zone}"`,
          },
          body: JSON.stringify({
            schedules,
            startTime: { dateTime: start, timeZone: time_zone },
            endTime: { dateTime: end, timeZone: time_zone },
            availabilityViewInterval: availability_view_interval,
          }),
        }
      )
    
      if (!response.ok) {
        throw new Error(`${response.status} ${await response.text()}`)
      }
    
      return await response.json()
    }
    

    Submitted by hugo989 6 hours ago

  • bunnative
    //native
    
    /**
     * Get Free/Busy Schedule
     * Get the free/busy availability of users, distribution lists or rooms (by email address) over a window of local times in `time_zone`. Requires Calendars.Read on the connection.
     */
    export async function main(
      auth: RT.Outlook,
      schedules: string[],
      start: string,
      end: string,
      time_zone: string = "UTC",
      availability_view_interval: number = 30
    ) {
      const response = await fetch(
        "https://graph.microsoft.com/v1.0/me/calendar/getSchedule",
        {
          method: "POST",
          headers: {
            Authorization: `Bearer ${auth.token}`,
            "Content-Type": "application/json",
            Accept: "application/json",
            Prefer: `outlook.timezone="${time_zone}"`,
          },
          body: JSON.stringify({
            schedules,
            startTime: { dateTime: start, timeZone: time_zone },
            endTime: { dateTime: end, timeZone: time_zone },
            availabilityViewInterval: availability_view_interval,
          }),
        }
      )
    
      if (!response.ok) {
        throw new Error(`${response.status} ${await response.text()}`)
      }
    
      return await response.json()
    }
    

    Submitted by hugo989 6 hours ago