Hello,
Not sure if anyone on here has worked with Constant Contact but I thought I would give it a shot. I am trying to upload contacts to their system via their API. All is fine until I try using what they call "Custom Fields". I can upload their predefined fields: First Name, Last Name, Email, etc... but I want to add a "Custom Field" to add our Customer Number.
Currently for testing I've created 1 custom fields labeled: 'custom_field_1' per their documentation.
This is the error I get when trying to add contacts with Custom Fields:
Array
(
[0] => stdClass Object
(
[error_key] => json.type.invalid
[error_message] => #/custom_fields: Value is of a disallowed type. Allowed types are: Array, Null.
)
)
Here is what I've tried:
// $custFPre = ['name' => 'custom_field_1', 'value' => '12345'];
// $custF = json_encode($custFPre);
$custF = '"custom_fields": [
{
"name": "custom_field_1",
"value": "343465"
}
]';
$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;
You'll see I tried 2 different ways of adding the custom field with JSON.
Here is their guide:
https://developer.constantcontact.com/docs/contacts-api/contacts-collection.html?method=POST#structure
I appreciate any thought/suggestions or if anyone else has run into this same issue.