Edits history of script submission #21970 for ' Update Record by ID (zoho)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Zoho = {
      token: string;
      baseUrl: string;
    };
    /**
     * Update Record by ID
     * This API updates a specific record displayed in a report of a Zoho Creator application. The record is identified by its ID value. The update operation is subject to data validations configured for the corresponding form.
     */
    export async function main(
      auth: Zoho,
      account_owner_name: string,
      app_link_name: string,
      report_link_name: string,
      record_ID: string,
      body: {
        result?: {
          fields?: string[];
          message?: false | true;
          tasks?: false | true;
        };
        data?: {};
        skip_workflow?: {}[];
      },
    ) {
      const url = new URL(
        `${auth.baseUrl}/creator/v2.1/data/${account_owner_name}/${app_link_name}/report/${report_link_name}/${record_ID}`,
      );
    
      const response = await fetch(url, {
        method: "PATCH",
        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