Creating a Clear Contacts Activity

webservices
Administrator

A new Activity is created by making an HTTP POST to the activity collection URI. In contrast to the Contact List, the Activity POST body is not an Atom Entry. Instead it is several named parameters encoded with one of the HTML FORM content types, either application/x-www-form-urlencoded or multipart/form-data. So the data passed in the POST body is the same as that produced by a FORM with the ENCTYPE attribute set to that type.

 

The "Clear Contacts" function works like the "Remove" function, except that you don't have to provide a list of email addresses that you wish to remove.  Select the lists you wish to clear carefully. If you clear contacts from all lists, you will not have any contacts left in your Constant Contact account.

 

You should refrain from additional operations on the list you are clearing until the job is complete. For example, adding contacts to the list before the clear contacts activity is complete may result in those new contacts being cleared when the activity is run.

 

Constructing an application/x-www-form-urlencoded Request

 

The basics of how to construct an application/x-www-form-urlencoded request are simple:

  1. Parameter names and values are escaped. Space characters are replaced by `+', and then reserved characters are escaped as described in [RFC1738], section 2.2: Non-alphanumeric characters are replaced by `%HH', a percent sign and two hexadecimal digits representing the ASCII code of the character. Line breaks are represented as "CR LF" pairs (i.e., `%0D%0A').
  2. The parameter name is separated from the value by `=' and name/value pairs are separated from each other by `&'.
  3. To use paramter values that contain delimiter characters, such as a comma, you need to enclose the value in double quotes, then encode the value.  For example, to use a parameter value of 'Boston, MA', you need to use '%22Boston%2C%20MA%22'.

Most programming languages have libraries that implement some or all of the encoding process. The parameters and their values are described in the table below. More details on how to make an application/x-www-form-urlencoded request are in the HTML specification.

 

The following example shows the parameters used to clear two contact lists, identified by ID's 2 and 5. Note that two contact lists are submitted in a single invocation of the Activities resource.

 

 activityType=CLEAR_CONTACTS_FROM_LISTS
&lists=http%3A%2F%2Fapi.constantcontact.com%2Fws%2Fcustomers%2Fjoesflowers%2Flists%2F2
&lists=http%3A%2F%2Fapi.constantcontact.com%2Fws%2Fcustomers%2Fjoesflowers%2Flists%2F5

application/x-www-form-urlencoded Parameters

 

Name Allowed values Description
activityType CLEAR_CONTACTS_FROM_LISTS The type of activity to create.  When clearing subscribers from the list, they will not be deleted, only removed from the list(s) specified. NOTE:  "Named" lists cannot be cleared. These incldude "Do-Not-Mail", "Removed", "Awaiting Confirmation", "All" and "Active". If an attempt to clear one of these lists (or another non-existant list) is made, the request will fail with a "400 Bad Request"
lists URI (one or more) The list to clear The list should be a list id URI as referenced in the Contact Lists Collection.

 

Constructing a multipart/form-data Request

 

When using FORMs, you must use enctype="multipart/form-data" when using <input type="file">. Similarly, when uploading a complete file of data, particularly binary data like MS Excel spreadsheets, you must use a multipart/form-data request. Most programming languages have libraries that implement some or all of the encoding process. The parameters and their values are described in the table below.. More details on how to make an multipart/form-data request are in the HTML specification and RFC 2388.

 

multipart/form-data Parameters

 

Name Allowed values Description
activityType CLEAR_CONTACTS_FROM_LISTS The type of activity to create.  When clearing subscribers from the list, they will not be deleted, only removed from the list(s) specified. NOTE:  "Named" lists cannot be cleared. These incldude "Do-Not-Mail", "Removed", "Awaiting Confirmation", "All" and "Active". If an attempt to clear one of these lists (or another non-existant list) is made, the request will fail with a "400 Bad Request"
lists URI (one or more) The list to clear. The list should be a list id URI as referenced in the Contacts List Collection.

 

If the new activity is created successfully, the server will return an HTTP status of 201 Created. The HTTP Location header in the response will contain the URI of the newly created activity, and the entity body returned will be the minimal entry for the activity, including server-generated values like ids and links:

 

<entry xmlns="http://www.w3.org/2005/Atom">
<link href="/ws/customers/joesflowers/activities/a07e1ffaxjyffmvqgiz" rel="edit" />
<id>http://api.constantcontact.com/ws/customers/joesflowers/activities/a07e1ffaxjyffmvqgiz</id>
<title type="text"></title>
<updated>2008-04-29T19:35:54.923Z</updated>
</entry>

Community Knowledge Base

Learning & Resources

We take questions asked by customers on the Community and expand on them to help you find answers fast, getting you back to using Constant Contact's suite of amazing tools in no time.

Read More

  • Avatar

    Support Tips

    Social Media

    "There's a multitude of ways to engage your audience through us using your social platforms - via ads, social post metrics, email links, and more! " - Will

    See Article
  • Avatar

    Support Tips

    Call-To-Action Links

    "Target your most engaged contacts by creating a segment. Create a special offer or show your appreciation!" - Caitlin

    See Article
  • Avatar

    Support Tips

    Welcome Your Audience

    "Greet new contacts with one or more automated Welcome Emails depending on their interests or your business goals." - Nick

    See Article