Get list & campaign details from ClientID

Using the c-sharp & .NET API, how do I get a list of our email lists and campaigns from the ClientID? 

I was able to the client ID with this code:

            List<BasicClient> clients = (List<BasicClient>)General.Clients();
            foreach (BasicClient c in clients)
                Console.WriteLine(string.Format("ID: {0}; Name: {1}", c.Name, c.ClientID));

However, nothing presents itself for getting other information.

jamesd jamesd, 6 years ago

Client.Lists, Client.Drafts, Client.Campaigns etc.

jamesd jamesd, 6 years ago

Hmm, it seems as though you are not using the latest version of the API, or the corresponding version of the .NET client library.

I would strongly recommend switching to using the current version of the API and the current version of the .NET client library.

northshore, 6 years ago

jamesd, Thanks for your post. I did check and I am using both the lastest API (v3) and .NET library (6/16/2011). 

I looked at the descriptions of Client.Lists and modified my code. 

            string clientID = "a1a1a1a1a1";
            Client c = new Client(clientID);
            List<BasicList> list = (List<BasicList>)c.Lists();
            foreach (BasicList bl in list)
            Console.WriteLine(string.Format("ID: {0}; Name: {1}", bl.ListID, bl.Name));

It seems like I should get the Campaign Monitor lists from the ClientID, but that is not the case.  Instead, I am getting the error: "Unable to cast object of type 'createsend_dotnet.BasicList[]' to type 'System.Collections.Generic.List`1[createsend_dotnet.BasicList]'."

How can I get the lists based on the ClientID?

northshore, 6 years ago

Found the problem: I used
List<BasicList> list = (List<BasicList>)c.Lists();

when I should have used
IEnumerable<BasicList> list = c.Lists();

See why 200,000 companies worldwide love Campaign Monitor.

From Australia to Zimbabwe, and everywhere in between, companies count on Campaign Monitor for email campaigns that boost the bottom line.

Get started for free