Edits history of script submission #14096 for ' Update a list entry (overwrite multiselect values) (attio)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Attio = {
      token: string;
    };
    /**
     * Update a list entry (overwrite multiselect values)
     * Use this endpoint to update list entries by `entry_id`. If the update payload includes multiselect attributes, the values supplied will overwrite/remove the list of values that already exist (if any). Use the `PATCH` endpoint to add multiselect attribute values without removing those value that already exist.
    
    Required scopes: `list_entry:read-write`, `list_configuration:read`.
     */
    export async function main(
      auth: Attio,
      list: string,
      entry_id: string,
      body: { data: { entry_values: {} } },
    ) {
      const url = new URL(
        `https://api.attio.com/v2/lists/${list}/entries/${entry_id}`,
      );
    
      const response = await fetch(url, {
        method: "PUT",
        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