Using Rest API to add email to a list

Regular Participant

Using Rest API to add email to a list

I used some VB.Net code I found to create a page that successfully adds contacts to the database, however I am having difficulty with adding them to the correct list.

I can add them to the first list (general interest) without problem, but if I change the list number to 3 (our third list), then I get an invalid page request... Here's the lines I have for addint to the list:

Dim sListUri As String = "" & sUsername & "/lists/3"
data.Append("&lists=" + HttpUtility.UrlEncode(sListUri))

Like I said, it works fine if the number on the end of the first line is '1', but it doesn't if it is '3'

Any suggestions?
Regular Participant

I would first double check that your account and make sure that your third list has a ID number 3.

You can use the Contact list Collection and the RestClient to retrieve the collection of contact lists and their ID numbers.

Contact list Collection


Mike C Support Engineer, Constant Contact

Regular Participant

Can I check the ID of the collection somewhere in the front end? Or is it only available through the API?
Regular Participant

I pulled a list of the lists and sure enough, even though the GUI had 3, it was listed as 4. changing to 4 worked like a charm.

The List number isn't entirely related to the way the GUI lays them out. Every new list you create will be in an incremented number in our database, this just means that you have created 4 lists in your account and one of them has been deleted.
Dave Berard
Senior Product Manager, Constant Contact

I am relatively new to .net and would like to see your VB code to add an email to a list in Constant Contact.

Developer Portal

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

Visit Page