Edits history of script submission #20537 for ' Move Folder (smartsheet)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Smartsheet = {
      token: string;
      baseUrl: string;
    };
    /**
     * Move Folder
     * Moves a folder.
     */
    export async function main(
      auth: Smartsheet,
      folderId: string,
      body: {
        destinationId: number;
        destinationType?: "folder" | "home" | "workspace";
      },
    ) {
      const url = new URL(`${auth.baseUrl}/folders/${folderId}/move`);
    
      const response = await fetch(url, {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
          Authorization: "Bearer " + auth.token,
        },
        body: JSON.stringify(body),
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 235 days ago