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.

Can same email address used repetitively?

HemalathaK
Regular Participant

Can same email address used repetitively?

I have updated contact with test@gmail.com. Can I add another contact with test@gmail.com with different details. if so can I know which HTTP request method I need to use? Thank you!!

 

Can anyone reply me urgently?

16 REPLIES 16
Nick_G
Moderator

Currently, our contact system is based off email addresses, so two contacts cannot exist with the same email address.

 

Nick Galbraith
Support Engineer
LonnieM
Occasional Participant

Thank you for clarification!!

I'd like to add to what Nick has stated. I've  provided a description of our contact data model that explains this more thoroughly here.  Essentially, contacts are unique at the account level in our system, and list are "interest" attributes of the contact record.

Mark Coleman
Support Engineer
HemalathaK
Regular Participant

 There is an emergency issue with this to my clients. Contacts are not getting updated once contact is register. is there a way that I could reach you guys?  Please help us out.

Seems like issue is with post. Once the contact is created then how can I get the right contact using GET when I have list number and email address? Please hlep me soon. Thanks!

Hi,

 

If you want to update existing contacts as well as add new contacts, you have to build in logic to do a search by email address, then PUT the contact if it already exists or POST the contact if it is new.  Here is my script that uses our PHP wrapper, for example.

 

<?php

session_start ();
require_once 'ConstantContact.php';
require_once 'config.php';

$ConstantContact = new ConstantContact("oauth2", $apikey, $username, $accessToken);  //OR
//$ConstantContact = new ConstantContact("basic", $apikey, $username, $password);
//Supply your credentials--API Key and other details--in config.php

// Get potential contact lists
$lists = $ConstantContact->getLists();
// Lists are returned in multidimentional arrays 0 being the list, and 1 being the next50

// Email address here is used for testing purposes
$emailAddress = "test_12132012@example.com";

// Search for our new Email address
$search = $ConstantContact->searchContactsByEmail($emailAddress);

// If the search didnt return a contact object
if($search == false)
{
	// Create a new Contact Object to store data into
	$contactObj = new Contact();
	// Adding multiple lists to this new Contact Object
	$contactObj->lists = array($lists['lists'][0]->id, $lists['lists'][1]->id);
	// Set the email address
	$contactObj->emailAddress = $emailAddress;
	//Set the opt in source
	$contactObj->optInSource = "ACTION_BY_CONTACT";
	// Create the Contact and DONE
	$Contact = $ConstantContact->addContact($contactObj);
	echo ("Contact added.");

} // Otherwise we update our existing contact
else 
{
	// Gather data from our previous search and store it into a data type
	$contactObj = $ConstantContact->getContactDetails($search[0]);

	 // We need to get the old list and add a new list to it as
	 // this request requires a PUT and will remove the lists
	 // as they are stored in an array
	 array_push($contactObj->lists, $lists['lists'][1]->id );
	 
	 //Set the opt in value
	 $contactObj->optInSource = "ACTION_BY_CONTACT";
	 $contactObj->firstName = 'firstname';
  	 $contactObj->lastName = 'CTCTlastname';
	// Update the contact and DONE
	$UpdateContact = $ConstantContact->updateContact($contactObj);
	
	echo ("Contact updated.");
}	

?>

 

 

Best Regards,

Shannon W.

API Support Specialist

HemalathaK
Regular Participant

Is there any Java code examples for the same issuer?

Actually my case is, I can't directly update existing contact and I should when it's not there in any lists but already registered and create a new one if not registered. And another thing is we don't have many list but just one so I knew list number.

 

 Thanks!

Hi.

 

That is what the script I posted above does.  If the contact is new, it adds them.  If the contact exists already, it updates them to make sure they are added to a list in the account.

 

Sorry, but I don't have any Java examples of this.

 

Best Regards,

Shannon W.

API Support Specialist

HemalathaK
Regular Participant

I'm using following for PUT method, giving 415 error. What's wrong with it? Thanks!

 


URI: https://api.constantcontact.com/ws/customers/testUser/contacts/212

 

Body:

 

<entry xmlns="http://www.w3.org/2005/Atom">
    <link href="/ws/customers/testUser/contacts/212" rel="edit"></link>
    <id>http://api.constantcontact.com/ws/customers/testUser/contacts/212</id>
    <title type="text">Contact: test@exampl.com</title>
    <updated>2013-03-01T20:23:39.599Z</updated>
    <author>
      <name>Constant Contact</name>
    </author>
    <content type="application/vnd.ctct+xml">
      <Contact xmlns="http://ws.constantcontact.com/ns/1.0/" id="http://api.constantcontact.com/ws/customers/testUser/contacts/212">
        <Status>Active</Status>
        <EmailAddress>test@exampl.com</EmailAddress>
        <EmailType>HTML</EmailType>
        <Name>test1, testF</Name>
        <OptInTime>2013-02-28T23:58:57.777Z</OptInTime>
        <OptInSource>ACTION_BY_CONTACT</OptInSource>
        <Confirmed>true</Confirmed>
        <InsertTime>2013-02-28T23:58:57.777Z</InsertTime>
      </Contact>
    </content>
  </entry>

A 415 error typically comes from an invalid content-type header, or not setting one. You'll need to set it as

Content-type: application/atom+xml

 If you currently have that set, just let us know, and we can take a deeper look.

Nick Galbraith
Support Engineer
LonnieM
Occasional Participant

Thanks that worked! Ok,

1) So when I update the  contact(existing email) with different details will it be seding confirmation email again to the user or not?

2) When update happens will it override existing details?

3)  I want to update existing contact only when it's not there in list but registered. But when it's in the list not yet exported then I don't want to update. What can I do for this? This is very very importatnt for my clients. Please let me know if you need clarification on this.

 

Thank you so much for your help on this!

Hi,

 

I'm glad you got this working.

 

1.  If you set the Opt in source to ACTION_BY_CONTACT, then the user will get an update notification but not a welcome email, since they've already received that once when they first subscribed.  If you set the opt in source to ACTION_BY_CUSTOMER, no emails will be sent.

 

2.  Yes, you will override existing contact details when you use the update function.

 

3.  It sounds like you need to build in logic to check if the user is registered or not before you use the update function.

 

Best Regards,

Shannon W.

API Support Specialist

HemalathaK
Regular Participant

Thanks for you reply!

 

Re. #3,  I'm checking whether registered or not, but what do I need to do for checking whether it's there in active list or not?

 

I would need some of the other info so soon. Is there a way I could reach you guys? Please let me know. Thanks!

Hello!

 

For #3 you can submit a GET request in this format to our API in order to check if a contact exists and is active:

https://api.constantcontact.com/ws/customers/{username}/contacts?email={email-address} 

 

If successful, this request will return limited details of the contact or fail if the email address does not match a contact on your account. You can find more information about this request here: 

http://community.constantcontact.com/t5/Documentation/Searching-for-a-Contact-by-Email-Address/ba-p/...

 

As a side note, you can then pass another request for more detailed information to our API using the contact's ID and the request format specified here: http://community.constantcontact.com/t5/Documentation/Obtaining-a-Contact-s-Information/ba-p/25057

 

 

In addition, if you do need to be able to speak with someone from our API support team, you would need to send an email to webservices@constantcontact.com and let us know what date/time is best for you. We will be sure to get back to you and let you know if there's a scheduling conflict or if we can connect at that time.

 

Sincerely,

Elijah G.

Tier 2 Support

Elijah G.
API Support Engineer
HemalathaK
Regular Participant

Thanks!!

Developer Portal

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

Visit Page