Duplicate emails not allowed ?

Highlighted
Occasional Contributor

Duplicate emails not allowed ?

Hello there !

 

I am using API to add my contact form information in specific lists. I submitted the form by selecting list1, And next time i submitted the form by selecting list2. I used same email id but different lists. But it's not allowing. I should add this email in different lists. Please suggest me what should i do in this case ?

 

Help will be highly appreciated !

 

Regards,

Thiru !

10 REPLIES 10
Highlighted
Honored Contributor

Re: Duplicate emails not allowed ?

Hello Thiru,


When you are adding contacts through the Constant Contact API, there are two thing to keep in mind:

1. When you are adding a new contact, it is sent as a POST request to Constant Contact. However, when you want to make a change to a contact that has already been added, you must submit it as a PUT request instead.

2. When you are adding a contact to Constant Contact, you do not need to submit the contact once per list. You can specify all of the lists at once when the contact is being added.

 

You can read more about creating contacts here: http://community.constantcontact.com/t5/Documentation/Creating-a-Contact/ba-p/25059

 

Also, if you do still need more assistance with creating and updating your contacts, it would be helpful if you could reply and include the code that is being used to submit the information to Constant Contact. Please remember to remove any sensitive information if you do post your code as this is a public forum.

 

Sincerely,

Elijah G.

Tier 2 Support

Elijah G.
API Support Engineer
Highlighted
Occasional Contributor

Re: Duplicate emails not allowed ?

Thanks for your reply on my question !

 

I have a contact form in my website. I have given lists in select box(ie: list1, list2, list3 etc....). Now user submitted the form  will all the details and select list1, list2 at this time. I can insert these details into my constant contact list1,list2.

 

In future the same user comes to my site and tried to submit the form with same email id but select different list(ie: list3) at this time. In this case constant contact is not allowing to add duplicate entry.

 

Please suggest me what should i do in this case?

 

If i try to update the list3 for same email, then i will lose rest of the details like notes(Which describes purpose of contact us from our website). Please suggest me ?

 

Regards,

Thiru !

Highlighted
Honored Contributor

Re: Duplicate emails not allowed ?

Hello Thiru,

 

In a case like this where a contact would come and input their information again, what you would want to do is use a GET request to the API to collect the contact's information before submitting an update. Then you can add the new list (list 3) to the existing lists and submit the contact. This way the information is updated rather than overwritten.

 

As an example, it would work something like this:

 

- Send a GET request to Constant Contact API and check if email@example.com is already an existing contact

- If they are, perform a second GET request to obtain the contact's details. This will include the lists that they are already a member of.

- Add any updated information to the existing contact information and submit the new data as a PUT request. This will update the record stored in Constant Contact.

 

If you have any questions about this, please reply to this post and I will be happy to assist you!

 

Sincerely,

Elijah G.

Tier 2 Support

Elijah G.
API Support Engineer
Highlighted
Occasional Contributor

Re: Duplicate emails not allowed ?

Thanks for giving quick reply !

 

Actually i am using ctct_php_library-master to add and update the contact information.

 

For adding : $ConstantContact->addContact($Contact);

For updating: $ConstantContact->updateContact($Contact); 

 

It's working fine for adding contact information. But it's giving an error while using updateContact(). The error is like: Method not allowed and response code is 405.

 

Can you please help me to update contact information in Lists?

 

And also please provide sample code for this, So that it help me more.

 

Regards,

Thiru !

Highlighted
Honored Contributor

Re: Duplicate emails not allowed ?

Hello Thiru,

 

If you are receiving an error 405 when trying to update a contact, that is likely related to an issue with the contact data that is being submitted to the updateContact method. Can you provide an example of the code that is creating the $Contact variable and populating the data?

 

Sincerely,

Elijah G.

Tier 2 Support

Elijah G.
API Support Engineer
Highlighted
Occasional Contributor

Re: Duplicate emails not allowed ?

Hello !

 

Below is my code which i am using for update existed contact !

 

$Contact = new Contact();
$Contact->emailAddress = 'redacted@example.com';
$Contact->firstName = $_POST['first_name'];
$Contact->lastName = $_POST['last_name'];
$Contact->lists = $_POST['lists'];
$Contact->notes = $_POST['contact_message'];
$Contact->optInSource = 'ACTION_BY_CONTACT';

$response = $ConstantContact->updateContact($Contact);

 

Please help me in this !

 

Regards,

Thiru !

Highlighted
Honored Contributor

Re: Duplicate emails not allowed ?

Hello Thiru,

 

When you want to update an existing contact, the firs thing to do is search and see if the contact already exists. Once you confirm that the contact exists, you can then add your updated information to the existing contact an update it. I have included an exmaple using your code below.

 

 

$results = $ConstantContact->searchContactsByEmail(redacted@example.com);
$Contact = $results[0];
$Contact->firstName = $_POST['first_name'];
$Contact->lastName = $_POST['last_name'];
$Contact->lists = array_merge($Contact->lists,$_POST['lists']); // Adding the array_merge here will add to your exists lists, rather than 
$Contact->notes = $_POST['contact_message'];
$Contact->optInSource = 'ACTION_BY_CONTACT';
$response = $ConstantContact->updateContact($Contact);

 

What this will do is to collect all of the existing contact information and add the changes. When you are using the updateContact method, you need to have a full contact's information or else it will fail. ONe thing you will likely want to do is add some verification to this code so that it will make sure a contact exists before trying to update it. You could do that by checking for a $Contact->emailAddress field since it will only be set when a contact is successfully fetched.

 

Feel free to reply if you do have additional questions for me.

 

Sincerely,

Elijah G.

Tier 2 Support

 

Elijah G.
API Support Engineer
Highlighted
Occasional Contributor

Re: Duplicate emails not allowed ?

Hello,

 

 

I really appreciate you !

 

It worked perfect, Thanks So Much !

 

Regards,

Thiru !

Highlighted

Re: Duplicate emails not allowed ?

hi thiru,

 

i need to develop single sign on using constant contact api. 

 

pls help me

  

Developer Portal

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

Visit Page

Constant Contact Would Like To Hear From You!

We want to hear from customers like you about your favorite features and how they have helped your business or organization. Tell us by answering a few questions in...

Read More
Featured