Followers Are Great, Contacts Are Gold. Create a Free AI-Quiz With Lead Magnet to Share With Your Followers and Own Your Contacts!

The remote server returned an error: (400) Bad Request.

MandiC77984
Campaign Collaborator
0 Votes

Here is my code ..I am getting issue get respoms

plz resolve my issue asap

 

string CCusername = "****";
string CCpassword = "****";
string CCuri = "https://api.constantcontact.com/ws/customers/" + CCusername + "/activities";

string CClistUri = "https://api.constantcontact.com/ws/customers/" + CCusername + "lists/1";
string CCAPIKEY = "******";

string Email = form["Email"].ToString();
string Name = form["Name"].ToString();

Uri address = new Uri(CCuri);
WebRequest request = WebRequest.Create(address);
request.Credentials = new NetworkCredential(CCAPIKEY + "%" + CCusername, CCpassword);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";

StringBuilder data = new StringBuilder();
data.Append("activityType=" + HttpUtility.UrlEncode("SV_ADD", Encoding.UTF8));
data.Append("&data=" + HttpUtility.UrlEncode(("Email Address,First Name" + "\n"), Encoding.UTF8));
data.Append(HttpUtility.UrlEncode((Email + "," + Name + ","), Encoding.UTF8));
data.Append("&lists=" + HttpUtility.UrlEncode(CClistUri));

Byte[] byteData = UTF8Encoding.UTF8.GetBytes(data.ToString());
String st = String.Empty;
request.ContentLength = byteData.Length;

Stream postStream = request.GetRequestStream();
using (postStream)
{
postStream.Write(byteData, 0, byteData.Length);
}

WebResponse response = request.GetResponse();

using (response)
{
StreamReader reader = new StreamReader(response.GetResponseStream());
st = reader.ReadToEnd();
}

0 REPLIES 0
Resources
Developer Portal

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

Visit Page