Use this endpoint to create an asynchronous background job that removes contacts from one or more contact lists by importing a list of contacts in binary form using the multipart content-type. The supported file types are:
Click a method to view its documentation
Privileges required: contacts:write
You can remove contacts from one or more contact lists using a .txt or .csv file that contains only the email addresses of the contacts to be removed. You need to use an HTTP multipart request in a POST to this endpoint. The multipart request contains three parameters:
data, defined in the Structure section below.
The size of the payload (import file) must be less than 4 megabytes. Also, you can remove a maximum of 20,000 contacts in a single POST. The activity will fail if the payload is greater than 4 MBs or if it includes more than 20,000 contacts.
The data file must contain only email addresses. Do not include any other data columns in the file, and do not include any labels or other non-email content in the file.
The following is an example multipart encoded post written in Java that removes contacts from contact lists 4 and 6 by importing a file (contacts.txt) containing only the email addresses of the contacts to remove:
final HttpClient httpclient = new DefaultHttpClient();
final HttpPost httppost = new HttpPost("https://api.constantcontact.com/v2/activities/removefromlists");
httppost.addHeader("Authorization", "Bearer 5e35af38-7b63-47cac-b484-20c4ff4d09c8");
final File fileToUse = new File("/path_to_file/contacts.txt"); //e.g. /temp/contact.txt
final FileBody data = new FileBody(fileToUse);
final String listIds = "1", "4";
final StringBody lists = new StringBody(listIds);
final StringBody fileName = new StringBody(fileToUse.getName());
final MultipartEntity reqEntity = new MultipartEntity();
final HttpResponse response = httpclient.execute(httppost);
final HttpEntity resEntity = response.getEntity();
To see the status of an activity, make a GET call to the URI returned in the response's location header:
Poll this URI to monitor the activity status until the status is either COMPLETE or ERROR, indicating that the activity has completed processing. The response structure for this GET call is detailed here.
See also: Summary Activity Reports API