Edits history of script submission #20502 for ' Get an Update Request (smartsheet)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Smartsheet = {
      token: string;
      baseUrl: string;
    };
    /**
     * Get an Update Request
     * Gets the specified update request for the sheet that has a future schedule.
    
    The rowIds and columnIds in the returned UpdateRequest object represent the list at the time
    the update request was created or last modified. The lists may contain Ids of rows or columns
    that are no longer valid (for example, they have been removed from the sheet).
    
     */
    export async function main(
      auth: Smartsheet,
      sheetId: string,
      updateRequestId: string,
    ) {
      const url = new URL(
        `${auth.baseUrl}/sheets/${sheetId}/updaterequests/${updateRequestId}`,
      );
    
      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