Want to store data in tabular format(same as rows in database)

Regular Participant

Want to store data in tabular format(same as rows in database)

Want to store data

1) what are the different form of input source we can use for adding, updating and deletiing data.

2) what APIs are available for the same operation.


Operations pertaining to your account are done through one of 4 HTTP operations (get, post, put, delete). Most of these operations either pass and/or receive XML, depending on what operation you are using. These methods can be used to interact with your contacts, contact lists, email campaigns, and campaign reporting. For more information on what you can use our API for, I would recommend checkout out our REST API Reference page.


We do have some sample code that can help get you started, which you can find under Sample Code.


If you are looking to store information from your Constant Contact account into your own database, you would need to make the appropriate calls to our API which will return XML containing the information you are looking for. You can then loop through that response and add all the data you are looking to store to your database.

David J

Regular Participant

Thanks David for the quick response! One more question.

I have a form which contains customer information like (customer id, customer name, customer email id, customer address etc) i want to store that information in my Constant Contact account. What would be steps and  what are the manadatory condition?

1) Do i need to put the customer information in xml and then send it to my Constant Contact account. If yes then what would be the format of XML?

2) Secondly, the tags of xml provided by Constant Contact are the only tags(</EmailAddress>) available? Can we make our own custom xml tag? if no, then how can we put different fields in XML.


3) which API stores data in tabular form? Please guide me if i am going wrong
-Creating a New List(https://api.constantcontact.com/ws/customers/{username}/contacts)
-Adding a Contact to a List(https://api.constantcontact.com/ws/customers/{username}/contacts/{contact-id}) 4) Yesterday i was able to connect to your web-server and added a constant contact through (https://api.constantcontact.com/ws/customers/{username}/contacts) need your support for clear understanding.

4) For example i have a data in this form
John,1962-11-24,accounting,senior accountant
Karen,1972-01-10, marketing,graphic designer
Sandra,1976-10-26,marketing,account manager

After converting the data to XML it would look like

<jobTitle>senior accountant</jobTitle>
<!-- and so forth -->
can i send this format to my constant contact account? If not then what would be the XML format.

5) Yesterday i was able to connect to your web-server and added a
constant contact through (https://api.constantcontact.com/ws/customers/{username}/contacts)
need your support for clear understanding.

Request: The link to sample code does not contain any java sample.
Can you please add some java sample code.



The contact information that you send to us would need to be in XML format. You can find sample XML for almost every operation on our Rest API Reference page. For example, Creating a new Contact, Creating a Contact List, Creating a Campaign. The tags that are provided by Constant Contact are the only tags which are allowed, and your XML request must be properly formatted in order to complete your request. If there is other contact information you are looking to store in your Constant Contact account for which we do not provide an appropriate field, you can make use of Custom Fields 1 - 15 which are available for each contact. You can find a list of all available fields for creating a contact and their allowed values at the bottom of our Contacts Collection Resource page.


 Looking at your example of the data you have in your form, you really have two options for importing these contacts through our API.


1) Use valid XML and perform an http POST to the Contacts Collection to create each of your contacts. This is the recommended method when adding a handful of contacts (ie: less than 25).


2) If you are uploading more than approx. 25 contacts, you may want to take a look at using our Bulk Activity. This will allow you to add multiple contacts by using a number of named parameters encoded with either the application/x-www-form-urlencoded or multipart/form-data HTML form content types. Please note that this is only for use of creating 25 or more contacts at a time and is not to be used for creating smaller sets of contacts.


In regards to your question about a java sample, unfortunately this is not something that we have available at this time.

David J

Regular Participant

Thanks once again! Some more queries!

I am done with the Creating a new Contact, Creating a Contact List, Creating a Campaign.

1) Query regarding  Creating a Campaign

             a) I have posted the same xml(through java code POST) that is there in your docs with some content modification. But i can't see the info neither when i am hitting the URI (https://api.constantcontact.com/ws/customers/{user-name}/campaigns)directly in the browser nor when i am calling it through the code(XML response). what's the issue behind this?

             b) If i want to get a mail from my account to see the look of Mail format how can i acheive that?

             c) As per the statement "You can get a list of campaigns avaialble in your account by using the GET method on the campaigns collection".I can't see that,  both through code and direct hit.


2) Query regarding Creating a Contact List:

             a) I  have added 5 different customer info in my constant contact a/c, but i can't see some data that i have posted with that customer, for example, address is not getting in the response when i am querying it through code.

             b) Moreover when i hit the URI directly in the browser after passing the authentication, it will show me only the list of emailID of the total customer.

              c) How can i see the complete data in the browser. All this i need to complete my testing whether the data i am sending or the format i have choosed for my mails are repositing in my account completely(properly) or not.

                 I need a proper dig of the capability of your API so that i can achive a thorough understanding and will contribute the best of my knowledge. On the whole, i need a complete cycle testing where i am acting as both data submitter and Mail getter.



Regarding Creating a Campaign

I took the exact URL that you posted (https://api.constantcontact.com/ws/customers/{user-name}/campaigns) and replaced '{user-name}' with my Constant Contact username, and it successfully returned the expected XML. If you were to use this URL in your browser, you should be prompted for your username and password. If you are running into issue with this, you may want to take a look at the REST Client which is an easy way to text your API calls and XML structures with detailed error messaging.


Depending on what browser you are using, it may render the XML differently (or prompt you to subscribe to an RSS feed). However, if you view the page source in your browser, it should show you the XML that was returned from our server. Again, I would recommend taking a look at the rest client to test your API calls, as this can provide a great deal of information and assist with troubleshooting.


Performing an http get on https://api.constantcontact.com/ws/customers/{user-name}/campaigns will return XML with an entry for each email listed in your account. If you wish to drill down further to get specific information from a particular email, you can reference the <id> node for that email and perform a get on that URI. (ie: https://api.constantcontact.com/ws/customers/{user-name}/campaigns/{campaign-id}) and it will return more detailed information for that specific email. You can find more information about this in our Campaign Collection and Resource Reference.  


As far as previewing the format of your email, the only option I can present for this is to log into Constant Contact, click on the "Email Marketing" tab, followed by the name of your email. On the right side of the screen you will see a 'preview' button which will let you see a preview of what the email will look like. You can also send a test email to your email address from this preview screen, to see how it will render in your email client.


Regarding Creating a Contact List

If you have created 5 new contacts, there are a few different ways to retrieve their data from the API.


1) Perform an HTTP on that contacts id (ie: https://api.constantcontact.com/ws/customers/{user-name}/contacts/{contact-id}). This will return detailed XML about this specific contact.


2) If you placed all of these contacts in the same contact list, you could perform an http get against the Contact List Members Collection which will return a response containing some information about the contacts contained within a specific list. To obtain the full contacts details you would need to access the contact ID. Please note, like all collections in our api, the XML returned will be a paged response if there are more than 50 contacts contained within a list.


3) You also have the option to Search for a Contact by Email Address which will allow you do perform an http get against a specific email address https://api.constantcontact.com/ws/customers/{username}/contacts?email={email-address}. This will return XML about this specific contact.


I hope this information helps. If you have any other questions please let us know. Thanks


David J

Regular Participant


The scenario of my question is that i have a list of clients(client email id), and further each client can have multiple categories which they offer to their customers(i.e newsletter, promotions etc), and further each categories can have multiple customer associated with it. Is it possile to store this type of information? Also how can we fetch list of customers by passing (client email id and category)?





I am a little unsure of the structure that you are looking for, but I will go into a little detail regarding how our system would function and hopefully this will answer your question.


Each specific account can have as many lists in it as you want. If you wanted, could have separate list for “newsletter” and “promotions”, and each of this lists could have a completely different set of contacts (but the same email address could certainly be added to both). Regarding making sublists underneath this level, that is not something that we support as this time.


With that being said, there are a few options that may work for what you are trying to do:


1)  You could make a separate set of lists in your account for each one of these clients. For example:

John – Newsletter

John – Promotions

Nancy – Newsletter

Nancy – Promotions


2)  Another option that may work for you would be to open up a solution provider account. A solutions provider can have multiple separate accounts underneath them, each of which would have its own set of contact lists and emails. You can visit the Solution Provider Partner Program for more information regarding this.


Regarding your question about fetching customers from a specific list, this can be done through the API by performing an http get on the following url format https://api.constantcontact.com/ws/customers/{user-name}/{list-id}/members. You could also use our bulk activity collection to export all of the contacts from a specific list into a CSV or text file that will be available for download. You can find more information on this in Creating an Export Contacts Activity.


I hope that this information helps. If you have any other questions or I misunderstood your question please let me know. Thank you.


David J

Regular Participant

Thanks David!

I can now add contacts to a list. One more question, just tell me weather it's a right approach or not. For creating a list and adding to that list i am generting an xml(same as in Constant Contact) and sending the XML by using POST method to the following URL

For create List:


and For adding to that list


My problem is that for every request(i.e for Creation, add, remove, update) i have to create a xml(programmatically). Following is the flow of creating an XML

Header of xml

and then the elements value which i am getting from my application

and lastly Footer, to make it a complete XML file, and then posting it through the above api's

Is there other way of generating the xml?





The method that you are using to create a contact as well as a contact list is correct. The method you choose to create your XML is up to you, but there is no way to automatically generate the XML for you. With that being said, many of our sample packs have a function in them that creates the basic XML needed for creating a contact or creating a list, and then simply inserts the relevant data from a form (or wherever your data is coming from), and finally doing an HTTP post to create that contact/list. This way you have 1 function that creates your XML, and all you need to do is update the structure with a few variables to create a contact/list.


I would recommend taking a look at one of our Sample Code packs for an example of how this can be achieved. I hope this answers your question, please let me know if you have any others and I will be happy to help. Thank you.

David J

Developer Portal

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

Visit Page