Edits history of script submission #14095 for ' Update a list entry (append 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 (append multiselect values)
     * Use this endpoint to update list entries by `entry_id`. If the update payload includes multiselect attributes, the values supplied will be created and prepended to the list of values that already exist (if any). Use the `PUT` endpoint to overwrite or remove multiselect attribute values.
    
    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: "PATCH",
        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