Edits history of script submission #21180 for ' Create Bulk Read job (zoho)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Zoho = {
      token: string;
      baseUrl: string;
    };
    /**
     * Create Bulk Read job
     * To create a bulk read job to export records.
     */
    export async function main(
      auth: Zoho,
      account_owner_name: string,
      app_link_name: string,
      report_link_name: string,
      body: {
        query?: { criteria?: string; max_records?: number; fields?: string[] };
      },
    ) {
      const url = new URL(
        `${auth.baseUrl}/creator/v2.1/bulk/${account_owner_name}/${app_link_name}/report/${report_link_name}/read`,
      );
    
      const response = await fetch(url, {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
          Authorization: "Zoho-oauthtoken " + 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