Find contact by custom field, update contact email, weird response

I am having a problem with the PHP wrapper trying to edit a contact to update their email address.

$url_params = 'limit=1&full=0&filters[fields][' . self::LOCAL_USER_ID_PERSONALIZATION_TAG . ']=' . $data->id;

try {
  $contact_list = $this->active_campaign->api( 'contact/list?' . $url_params );
} catch( Exception $e ) {
  write_log( $e );
}

$contact_id = reset( $contact_list )->id;

$contact['id']          = contact_id;
$contact['email']       = $data->email;
$contact['first_name']  = $data->first_name;
$contact['last_name']   = $data->last_name;

try {
  $contact_edit = $this->active_campaign->api( 'contact/edit', $contact );
} catch( Exception $e ) {
  write_log( $e );
}

write_log( $contact_edit );

The contact is not updated and the output of $contact_edit is

2 Likes

I can’t seem to edit posts on here, so I just wanted to note there is a typo in my post where $contact['id'] = $contact_id; that is not part of my issue here.

I see that my post got truncated somehow… argh… and I can’t edit it, double arghhh…

The contact is not updated and the response is:

[02-May-2018 19:11:12 UTC] stdClass Object
(
    [result_code] => 0
    [result_message] => You did not select any lists.
    [result_output] => json
    [http_code] => 200
    [success] => 0
    [error] => You did not select any lists.
)

Solved this by getting the full contact object from the contact/list endpoint, capturing the listid parameter, and adding the p[ID] = ID to the $contact before hitting contact/edit. This post was a hint.

It’s strange as I was not updating any custom fields.

Hopefully this helps someone else.