The Community is hosting an End of Summer sweepstakes! Participants must complete tasks to earn tickets that will enter them with a chance to win a free year of Constant Contact and other great prizes!*
*No Purchase Necessary. For Official Rules, visit here. Constant Contact’s End of Summer 2020 Sweepstakes ends on October, 20, 2020 at 11:50 PM EST.

Creating New List using C# Library

SOLVED
Go to solution
Highlighted
Occasional Contributor

Creating New List using C# Library

 

I am trying to create a new list through the API, using the C# Wrapper Library.

I am using the following code, but it is not creating a new list.

It seems to give me back the Atom code in the stringBuilder, but it seems to do nothing else.

 

The line after that does give me back the lists that I have currently, successfully.

 

Anyone know what I am missing?

 

Thanks so much for the help!!!

 

 

 

 

 

 

AuthenticationData authdata = newAuthenticationData();

                authdata.Username ="myusername";

                authdata.Password ="mypassword";

                authdata.ApiKey ="4600006d-0000-0000-0000-9500000003e1";

               

string nextLink;

 

               

               

Utility.IsValidUserAuthentication(authdata);

               

//Create New List              


               

StringBuilder sb = newStringBuilder();

               

ContactList myNewList = newContactList();

                myNewList.Id ="199";

                myNewList.Name ="SAMPLELIST";

                myNewList.OptInDefault =false;

                sb =

ContactListComponent.CreateNewContactList(myNewList);

               

               

IList<ContactList> lists = Utility.GetUserContactListCollection(authdata, out nextLink);

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Moderator

Re: Creating New List using C# Library

You're really close.  The lines you need to change are:

 

ContactList myNewList = newContactList();

                myNewList.Id ="199";

                myNewList.Name ="SAMPLELIST";

                myNewList.OptInDefault =false;

sb = ContactListComponent.CreateNewContactList(myNewList);

 

You would actually want to use the Utility class to create the list like this:

 

ContactList myNewList = Utility.addList("SAMPLELIST", false, authdata);

 

This would create a new list named SAMPLELIST with optinDefault set to false.  If you want to change the sort order, it would require a code change to the addList() method to allow a 4th param to be passed that is then leveraged in the XML builder.

 

Hope this helps! 

Dave Berard
Senior Product Manager, Constant Contact

View solution in original post

4 REPLIES 4
Highlighted
Occasional Contributor

Re: Creating New List using C# Library

By the way, I am using the .05 version.

Going through the posts, it looks like you used to be able to call something like this:

Utility.AddList()

 

But that doesn't appear to be available in the new version.

Highlighted
Moderator

Re: Creating New List using C# Library

You're really close.  The lines you need to change are:

 

ContactList myNewList = newContactList();

                myNewList.Id ="199";

                myNewList.Name ="SAMPLELIST";

                myNewList.OptInDefault =false;

sb = ContactListComponent.CreateNewContactList(myNewList);

 

You would actually want to use the Utility class to create the list like this:

 

ContactList myNewList = Utility.addList("SAMPLELIST", false, authdata);

 

This would create a new list named SAMPLELIST with optinDefault set to false.  If you want to change the sort order, it would require a code change to the addList() method to allow a 4th param to be passed that is then leveraged in the XML builder.

 

Hope this helps! 

Dave Berard
Senior Product Manager, Constant Contact

View solution in original post

Highlighted
Moderator

Re: Creating New List using C# Library

I wasn't aware that this was taken out of the latest version.  I will look at the latest code repository and get back to you.  The last update we did was only supposed to change the target build environment to be backwards compatible to Visual Studio 2008 (the project was upgraded to 2010 on our development environment and customers with an older version were no longer able to access the code).

 

If you have VS2010, you can continue to use the older version without any missing functionality.  That could be a potential solution for you while we look into this more.

Dave Berard
Senior Product Manager, Constant Contact
Highlighted
Occasional Contributor

Re: Creating New List using C# Library

Dave, sorry, I found it.

I must have been grabbing the .dll from another directory.

I found the one I was looking for under \Development\ConstantContactUtility\debug

 

That .dll has the "AddList"

Developer Portal

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

Visit Page

Constant Contact 2020 End of Summer Community Sweepstakes!

The Constant Contact User Community is hosting a sweepstakes. The more you participate, the more chances you have to win! Read on to learn more...

Read More
Featured