The Community is hosting an End of Summer sweepstakes! Participants must complete tasks to earn tickets that will enter them with a chance to win a free year of Constant Contact and other great prizes!*
*No Purchase Necessary. For Official Rules, visit here. Constant Contact’s End of Summer 2020 Sweepstakes ends on October, 20, 2020 at 11:50 PM EST.

api v2 C# - how to get contacts from "do-not-mail" list

Highlighted
Occasional Advisor

api v2 C# - how to get contacts from "do-not-mail" list

In v1 of API, you could do something like the code below to fetch the members of the do not mail list.  I don't even see this list in the results from the "contact list collection."  Nor can you fetch it by list id of "do-not-mail"

 

String nextLink;
List<Contact> contacts = (List<Contact>) Utility.getListMembers("/ws/customers/"+authdata.Username+"/lists/do-not-mail", authdata, out nextLink);
while(nextLink != ""){
      List<Contact> nextPageContacts = (List<Contact>)    Utility.getListMembers("https://api.constantcontact.com"+nextLink, authdata, out nextLink);
      contacts.AddRange(nextPageContacts);

 

5 REPLIES 5
Highlighted
Employee

Re: api v2 C# - how to get contacts from "do-not-mail" list

Hi Rich,

 

We are working to add functionality to the V2 API so that it can retrieve system lists (e.g. removed, do-not-mail, active, etc).  There currently isn't a way to do so in V2.  I will follow up with our product manager to make sure it is in the pipeline.  Thanks!

 

Best Regards,

Shannon W.

API Support Specialist

Highlighted
Visitor

Re: api v2 C# - how to get contacts from "do-not-mail" list

Where is this feature at?

Highlighted
Moderator

Re: api v2 C# - how to get contacts from "do-not-mail" list

This feature has actually been released since our launch in April, just in a slightly different way than we had done in the V1 API.  To get all the Contacts with a specific subscription status, you would do a GET agains the Contacts collection and filter based on status.  Our documentation on this is found here: http://developer.constantcontact.com/docs/contacts-api/contacts-collection.html

Dave Berard
Senior Product Manager, Constant Contact
Highlighted
Occasional Advisor

Re: api v2 C# - how to get contacts from "do-not-mail" list

This isn't the way the C# libraries in github work.   While the "listId"  in CTCT.ConstantContact.GetContactsFromList is typed as string, it only supports integers, maybe down at the service level.  I haven't had time to debug it yet.  So with an integer for listId, there's no way to specify "OPTOUT" or "REMOVED".

 

https://github.com/constantcontact/.net-sdk/blob/3d729e854a1f3ba21401afdb4ec9b59d4ba5eead/CTCTWrappe...

 

https://github.com/constantcontact/.net-sdk/blob/3d729e854a1f3ba21401afdb4ec9b59d4ba5eead/CTCTWrappe...

 

I've been using the version 1 API for these calls where you can do:

 

Utility.getListMembers("do-not-mail", _auth, out nextLink);

or

Utility.getListMembers("removed", _auth, out nextLink);

 

 

Highlighted
Moderator

Re: api v2 C# - how to get contacts from "do-not-mail" list

It looks like we haven't added the status query parameter to the GetContacts call.  The GetLists call will no longer support system lists, only user defined lists (which is why you are getting the invalid ID error).  See our documentation for how the status query parameter works for the Contacts collection.

 

Will get this in the queue to add to the C# wrapper.  If you are unable to wait, feel free to do the update to the wrapper and request a pull and we'll look over the request and merge it in if there aren't any problems.  If not, it could be a couple of weeks to get this added as we are doing so other major updates at the same time.

Dave Berard
Senior Product Manager, Constant Contact
Developer Portal

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

Visit Page

Constant Contact 2020 End of Summer Community Sweepstakes!

The Constant Contact User Community is hosting a sweepstakes. The more you participate, the more chances you have to win! Read on to learn more...

Read More
Featured