Edits history of script submission #23342 for ' List Calendars (outlook)'

  • bunnative
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    
    /**
     * List Calendars
     * List the connected account's calendars, including shared ones it has added. Requires Calendars.Read (covered by the default Calendars.ReadWrite).
     */
    export async function main(
      auth: RT.Outlook,
      top: number = 100,
      next_link: string | undefined
    ) {
      if (
        next_link != null &&
        next_link !== "" &&
        !next_link.startsWith("https://graph.microsoft.com/")
      ) {
        throw new Error(
          "next_link must be an @odata.nextLink returned by Microsoft Graph"
        )
      }
      let url: URL
      if (next_link != null && next_link !== "") {
        url = new URL(next_link)
      } else {
        url = new URL("https://graph.microsoft.com/v1.0/me/calendars")
        url.searchParams.append("$top", String(top))
      }
    
      const response = await fetch(url, {
        headers: {
          Authorization: `Bearer ${auth.token}`,
          Accept: "application/json",
        },
      })
    
      if (!response.ok) {
        throw new Error(`${response.status} ${await response.text()}`)
      }
    
      return await response.json()
    }
    

    Submitted by hugo989 6 hours ago

  • bunnative
    //native
    
    /**
     * List Calendars
     * List the connected account's calendars, including shared ones it has added. Requires Calendars.Read on the connection.
     */
    export async function main(
      auth: RT.Outlook,
      top: number = 100,
      next_link: string | undefined
    ) {
      if (
        next_link != null &&
        next_link !== "" &&
        !next_link.startsWith("https://graph.microsoft.com/")
      ) {
        throw new Error(
          "next_link must be an @odata.nextLink returned by Microsoft Graph"
        )
      }
      let url: URL
      if (next_link != null && next_link !== "") {
        url = new URL(next_link)
      } else {
        url = new URL("https://graph.microsoft.com/v1.0/me/calendars")
        url.searchParams.append("$top", String(top))
      }
    
      const response = await fetch(url, {
        headers: {
          Authorization: `Bearer ${auth.token}`,
          Accept: "application/json",
        },
      })
    
      if (!response.ok) {
        throw new Error(`${response.status} ${await response.text()}`)
      }
    
      return await response.json()
    }
    

    Submitted by hugo989 6 hours ago