Edits history of script submission #14390 for ' Get allowed collaboration domain (box)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Box = {
      token: string;
    };
    /**
     * Get allowed collaboration domain
     * Returns a domain that has been deemed safe to create collaborations
    for within the current enterprise.
     */
    export async function main(
      auth: Box,
      collaboration_whitelist_entry_id: string,
    ) {
      const url = new URL(
        `https://api.box.com/2.0/collaboration_whitelist_entries/${collaboration_whitelist_entry_id}`,
      );
    
      const response = await fetch(url, {
        method: "GET",
        headers: {
          Authorization: "Bearer " + auth.token,
        },
        body: undefined,
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 235 days ago