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.

Issues with API v2


Issues with API v2



I am new to ConstantContact, and was playing around with the API to understand how things work. I was trying to do an upload of some 18k contacts through the API to my constant contact account. Before I did that, there were about 18k contacts already in my account which I deleted entirely.


When I tried to run the code that uploads contacts using AddContact() method, I was getting an exception that said "contact with email ID already exists". I do not have any contacts in my account so the exception error did not make sense to me. When I debugged the application, I observed that the contact with the same emailID was being found and that the existing contact status is "REMOVED".


I am confused as to whether this is some kind of a bug in the API. Can someone help me with this.



Here is my relavant C# code:


foreach (DataRow row in dtUsers.Rows)
                bool contactExists = false;

                if (contactService.GetContacts(Convert.ToString(row["sEmailID"]), null, null, null).Results.Count > 0)
                    contactExists = true;

                if (!contactExists)
                    Contact ct = new Contact();
                    ct.FirstName = Convert.ToString(row["sFirstName"]);
                    ct.LastName = Convert.ToString(row["sLastName"]);
                    ct.Id = Convert.ToString(row["sID"]);
                    ct.CompanyName = Convert.ToString(row["sOrganizationName"]);
                    ct.Status = "ACTIVE";

                    EmailAddress em = new EmailAddress(Convert.ToString(row["sEmailID"]));


                    contactService.AddContact(ct, false);


For each row of the 18k rows in dtUsers, I get ContactExists=true, but the fact is I do not have any contacts in my account at all.











In this case what you are seeing is actually the expected behavior for our APIs when a contact is deleted. This is because our system soft-deletes contacts so that they can be later restored with their previous details intact. As a result of this, your code is detecting these deleted contacts with the expected status of REMOVED.


For an integration that will be modifying contacts individually, the correct approach is to search for an existing contact, and then either update the existing contact or create a new contact accordingly. You can read more about the suggested approach for managing contacts here: http://developer.constantcontact.com/docs/developer-guides/working-with-contacts.html#create_contact


In a case such as yours where you will be updating a large number of contacts, I would advocate the use of our asynchronous bulk import API, as it will automatically add/update contacts as appropriate and avoids the difficulty of manually detecting and handling that situation for each individual contact. You can find the API documentation for bull import here:



And in order to implement this with the .NET SDK, you will need to use the following:

  • ActivityService
  • AddContacts
  • AddContactsImportData


The basic process is to assemble a list of AddContactsImportData objects (with each instance representing one contact), and use them along with a set of lists and columns to populate the AddContacts object. You then use the ActivityService.CreateAddContactsActivity method to initiate the import.


If you have any questions for me, please let me know!



Elijah G.
API Support Engineer
Developer Portal

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

Visit Page