We all started somewhere! Share your experience on the Get Advice: Let's Get Started Sweepstakes thread and be entered to win a $100 credit on your Constant Contact account.

Getting Next Page with .NET API


Getting Next Page with .NET API

I don't know how to get the next page of results when using the C# .Net API.


I can get the first page using:


var clist = _constantContact.GetContacts(lastModified);


I've tried things like:


var myPage = new CTCT.Components.Pagination();

myPage.Next = clist.Meta.Pagination.GetNextUrl();

clist = _constantContact.GetContacts(lastModified, myPage);


with no success.   

Anyone know how to do this?




You're actually very very close! With your example where clist is set as the ResultSet containing the first page of contacts, you can get the second page like this:

// Set up a list to hold all of the contacts from each page.
List<Contact> contacts = new List<Contact>();

// Get the first page
var clist = _constantContact.GetContacts(lastModified);

// store the first page

// Get the next page. To do this,you have to provide the actual pagination object rather than just the URL.
clist = _constantContact.GetContacts(lastModified, clist.Meta.Pagination);

// store the next page


You will want to keep in mind this is a very basic example. If you don't have a predictable number of pages, it would likely be best to set up a loop of some sort to repeat the process until there is not another page. In addition, with this method all of the contacts are compiled as you go.


Let me know if you have any questions!



Elijah G.

API Support Specialist

Elijah G.
API Support Engineer
Developer Portal

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

Visit Page