I'm getting this message when trying to post an individual contact through https://api.constantcontact.com/v2/contacts
json.payload.type.unexpected:We expected a json array but we received an a json object for one of the fields in the payload.
I'm using the .NET wrapper and it is building the json like this:
{"addresses":[],"custom_fields":[],"email_addresses":[{"email_address":"supercamilo@gmail.com","opt_out_date":"2014-07-25T00:00:00-04:00","status":"OPTOUT"}],"lists":[{"created_date":"2014-07-28T19:14:34.000Z","id":"2047522211","modified_date":"2014-07-28T19:14:34.000Z","name":"CMS Email Synced","status":"HIDDEN"}],"notes":[],"status":"UNCONFIRMED"}
Solved! Go to Solution.
Hello,
After looking into this, the error is actually being thrown because you're including an opt-out date on the contact when you create it. This is significant because that field is read-only and not valid when creating a new contact. If your goal is to import a contact directly to the unsubscribed category, that is unfortunately not possible through the API at this time. You can however immediately unsubscribe a contact after adding them by using the DeleteContact method. Here's an example:
ConstantContact ctct = new ConstantContact(API_KEY); Contact unsubscribed = new Contact(), newContact; // Set Contact Data Here // Add the contact to CTCT and collect the API response with ID. newContact = ctct.AddContact(unsubscribed); // Delete(unsubscribe) the new contact immediately ctct.DeleteContact(newContact);
If you are still having any trouble after this, please let us know!
Best Regards,
Hello,
After looking into this, the error is actually being thrown because you're including an opt-out date on the contact when you create it. This is significant because that field is read-only and not valid when creating a new contact. If your goal is to import a contact directly to the unsubscribed category, that is unfortunately not possible through the API at this time. You can however immediately unsubscribe a contact after adding them by using the DeleteContact method. Here's an example:
ConstantContact ctct = new ConstantContact(API_KEY); Contact unsubscribed = new Contact(), newContact; // Set Contact Data Here // Add the contact to CTCT and collect the API response with ID. newContact = ctct.AddContact(unsubscribed); // Delete(unsubscribe) the new contact immediately ctct.DeleteContact(newContact);
If you are still having any trouble after this, please let us know!
Best Regards,