API Add Contact with Custom Fields - Account Number

SOLVED
Go to solution
Frequent Participant

API Add Contact with Custom Fields - Account Number

Hello,

 

I am trying to upload a contact via the API and I'd like to also add their Account Number during the upload of the contact.  Here is what I've tried with no success:

 

$custF = [];
$custF = ['account_number' => '12345'];

$contact = new Contact();
$contact->addEmail($_POST['email']);
$contact->addList('1285823438');
$contact->addList('1597339570');
$contact->addList('1717557123');
$contact->first_name = $_POST['first_name'];
$contact->last_name = $_POST['last_name'];
$contact->custom_fields($custF);

 

I thought I read it needs to be in an array but that doesn't seem to work. I also tried:

 

$contact->custom_fields->account_number('12345');

and

$contact->account_number('12345');

 

I cannot find any documentation on this as well.

I appreciate any insight.

1 ACCEPTED SOLUTION

Hello,

 

It looks like you're using our SDK, so you don't need to JSON encode your content.

 

You can pass your custom field in by creating a custom field component, setting the values, and then adding it to the contact object.

$customField = new CustomField();
$customField->name = "CustomField1";
$customField->value = "343465";
$contact->addCustomField($customField);

 

Please give this a try and let me know if you're still seeing issues.


Regards,
David B.
Tier II API Support Engineer

View solution in original post

11 REPLIES 11
Developer Portal

View API documentation, code samples, get your API key.

Visit Page