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.

Constant Contact Would Like To Hear From You!

We want to hear from customers like you about your favorite features and how they have helped your business or organization. Tell us by answering a few questions in...

Read More
Featured