Some of our customers are experiencing difficulty logging in. We are aware of this issue and are working to resolve it as quickly as we can.

Need help adding a Contact through the C# api wrapper


Need help adding a Contact through the C# api wrapper

I am trying to integrate Constant Contact into our application. My goal is to automatically add the contact to the client's Constant Contact account when they add a contact in our application. Eventually we will add more but this is step 1.


I have downloaded the C# wrapper and successfully ran it using my Auth Data. I am having trouble adding a contact as it wants the list to add the contact to. I am wanting to add the contact to the accounts default list or pull back all of the contact lists and display them as check boxes in my application so my clients can choose which lists to add a new contact to.


1.  At this point I am getting an error trying to add a contact because no list is specified. How do I specify the default list?

2. I do not see any methods in the api wrapper to pull back the list collection. Is this not available?


Thanks for any ideas/help!


Dog Biz Pro


Hey Stephanie,


You would create a contact like this:


                myAuth.Username = "username";
                myAuth.Password = "password";
                myAuth.ApiKey = "apikey";
                Contact theContact = new Contact();
                theContact.EmailAddress = emailAddressText.Text;

                ContactOptInList theList = new ContactOptInList();
                theContact.OptInSource = ContactOptSource.ActionByContact;
                theList.ContactList = new ContactList("1");


                ConstantContactUtility.Utility.CreateNewContact(myAuth, theContact);

 As far as getting the entire list collection, this would be how:


private void login_btn_Click(object sender, EventArgs e)

            authdata = new AuthenticationData();
            authdata.Username = username_txt.Text;
            authdata.Password = password_txt.Text;
            authdata.ApiKey = "APIKEY";  // Insert your API key
            String nextChunkId, currentChunkId = null;
            List<ContactList> ContactLists = new List<ContactList>();

            // Takes all contact lists
                    ContactLists.AddRange((List<ContactList>)Utility.GetUserContactListCollection(authdata, currentChunkId, out nextChunkId));
                    currentChunkId = nextChunkId;

                } while (nextChunkId != "");

                StringBuilder s = new StringBuilder();
                foreach (ContactList n in ContactLists)

                displayLists_txt.Text = s.ToString();

            catch (Exception ex)
                errorHandler_lbl.Text = "please try logging in again";



Let me know if that helps.

Ryan Davis
Quality Engineer
Developer Portal

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

Visit Page