We all started somewhere! Share your experience on the Get Advice: Let's Get Started Sweepstakes thread and be entered to win a $100 credit on your Constant Contact account.

Unable to update custom fields through API

Occasional Participant

Unable to update custom fields through API


I'm using the CTCTWSJavaLib Java library to update contact information using the API. I have no problem updating standard fields, such as "CompanyName" and "Addr1", but my updates to custom fields, such as "CustomField7" or "CustomField10", are not being saved. In my case, "CustomField7" (but not "CustomField10") has been renamed through the Join My Mailing List screens, but the updates don't work through the API using both the original name ("CustomField7") or the new name. I'm wondering what is it that I'm doing wrong, as custom fields are listed as editable on the API documentation (http://developer.constantcontact.com/doc/contactCollection).

I would appreciate any help with this.


Occasional Participant

I found a solution for this. I downloaded the source code for the CTCTWSJavaLib and inspected it. The javadoc for the Contact class does mention the fields that are retrieved and updated, and custom fields are not considered; that's why they are not updated with my request. However, it's easy to modify the source code to include the custom fields. In case anyone is interested, here's what I did (keep in mind that this may not be the optimal solution):

On Contact.java, on the generateAttributesXmlRequest() method, I added the following lines between the lines that append the "Notes" attribute and those that append the "ContactLists" element:



String customFieldName = "";

for (int i = 1; i <= 15; i++) {

customFieldName = "CustomField" + i;

if(hasAttribute(customFieldName)) {

builder.append("<" + customFieldName + ">");


builder.append("</" + customFieldName + ">");





 This takes care of sending the values of the custom fields (1 to 15) in the request. To retrieve the values of the custom fields from the response, I added the following lines to the end of the if block of the endElement() method of the same class, that is, Contact (if you take a look at the source code, it's immediately evident where these lines should be placed):


else if(qName.startsWith("CustomField")) {

attributes.put(qName, currentString);


This takes care of retreiving the values of the 15 custom fields. 

Let me know what you all think (there may be a better solution).



Thanks for the update.  The Java code you are talking about I believe is an open source library.  Have you considered contributing and updating the code to reflect this for future users?  Any help contributing to the open source community is greatly appreciated.

Dave Berard
Senior Product Manager, Constant Contact
Developer Portal

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

Visit Page