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));
            Console.ReadLine();

However, nothing presents itself for getting other information.
Thanks.

jamesd jamesd, 5 years ago

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

jamesd jamesd, 5 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, 5 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));
            Console.ReadLine();

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, 5 years ago

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

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

200,000 companies around the world can't be wrong.

From Australia to Zimbabwe, and everywhere in between, companies count on 
Campaign Monitor for email campaigns that drive real business results.

Get started for free
1-888-533-8098