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 a campaign

Highlighted
Participant

creating a campaign

Hi 


please help me out to create the string builder to create a campaign. 


I use the following string builder to create a contact list. Do i need to create the string builder in the same way. Please advice me. Please send me a modal if you don't mind.


 


 


private string CreateaContactList(string sUserName, string sPassWord, string Listame) //success


    {


    //https://api.constantcontact.com/ws/customers/{username}/campaigns 


        string sCampUri = "https://api.constantcontact.com/ws/customers/" + sUserName + "/lists";


        string sAPIKey = "84325c7d-79ae-4754-aeeb-788006cc0745";


        Uri address = new Uri(sCampUri);


        HttpWebRequest request = WebRequest.Create(address) as HttpWebRequest;


        request.Credentials = new NetworkCredential((sAPIKey + "%" + sUserName), sPassWord);


        request.Method = "POST";


        request.ContentType = "application/atom+xml";


        //atom+xml";


        StringBuilder data = new StringBuilder();


 


        data.Append(@"<entry xmlns=""http://www.w3.org/2005/Atom"">");


        data.Append(@"<id>data:,</id>");


        data.Append(@"<title/>");


        data.Append(@"<author/>");


        data.Append(@"<updated>" +System.DateTime.Now.ToString()+"</updated>");


        data.Append(@"<content type=""application/vnd.ctct+xml"">");


        data.Append(@"<ContactList xmlns=""http://ws.constantcontact.com/ns/1.0/"">");


        data.Append(@"<OptInDefault>false</OptInDefault>");


        data.Append(@"<Name>" + Listame + "</Name>");


        data.Append(@"<SortOrder>92</SortOrder>");


        data.Append(@"</ContactList>");


        data.Append(@"</content>");


        data.Append(@"</entry>");


        //Email Address,Email Type,First Name,Last Name


        byte[] byteData = UTF8Encoding.UTF8.GetBytes(data.ToString());


        string st = String.Empty;


        request.ContentLength = byteData.Length;


        using (Stream postStream = request.GetRequestStream())


        {


            postStream.Write(byteData, 0, byteData.Length);


        }


        


            using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)


            {


                // Get the response stream  


                StreamReader reader = new StreamReader(response.GetResponseStream());


                st = reader.ReadToEnd();


            }


return st;


        }


Thanks in advance,


Pradeep


 

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