Edits history of script submission #14448 for ' List all classifications (box)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Box = {
      token: string;
    };
    /**
     * List all classifications
     * Retrieves the classification metadata template and lists all the
    classifications available to this enterprise.
    
    This API can also be called by including the enterprise ID in the
    URL explicitly, for example
    `/metadata_templates/enterprise_12345/securityClassification-6VMVochwUWo/schema`.
     */
    export async function main(auth: Box) {
      const url = new URL(
        `https://api.box.com/2.0/metadata_templates/enterprise/securityClassification-6VMVochwUWo/schema`,
      );
    
      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