Hi ,
I am using bulk activities collection.
I want to export the contacts under a contact list. I am using the following code for that.
But I am getting 400 Bad request error. Please help me out to find where could be the error.
The following is the method I am using.
Regards
Pradeep.
private string Export()
{
string sUserName = "USERNAME";
string sPassWord = "PASSWORD";
string sUri = "http://api.constantcontact.com/ws/customers/" + sUserName + "/activities";
string sAPIKey = "CCAPIKEY";
string sListUri = "http://api.constantcontact.com/ws/customers/" + sUserName + "/lists/2";
Uri address = new Uri(sUri);
HttpWebRequest request = WebRequest.Create(address) as HttpWebRequest;
request.Credentials = new NetworkCredential((sAPIKey + "%" + sUserName), sPassWord);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded ";
StringBuilder data = new StringBuilder();
data.Append("activityType=" + HttpUtility.UrlEncode("EXPORT_CONTACTS", Encoding.UTF8));
data.Append("&fileType=" + HttpUtility.UrlEncode("CSV", Encoding.UTF8));
data.Append("&exportOptDate=" + HttpUtility.UrlEncode("true", Encoding.UTF8));
data.Append("&exportOptSource=" + HttpUtility.UrlEncode("true", Encoding.UTF8));
data.Append("&exportListName=" + HttpUtility.UrlEncode("true", Encoding.UTF8));
data.Append("&sortBy=" + HttpUtility.UrlEncode("true", Encoding.UTF8));
data.Append("&columns=" + HttpUtility.UrlEncode("Email Address" , Encoding.UTF8));
data.Append("&columns=" + HttpUtility.UrlEncode("First Name", Encoding.UTF8));
data.Append("&columns=" + HttpUtility.UrlEncode("Last Name", Encoding.UTF8));
data.Append("&lists=" + HttpUtility.UrlEncode(sListUri));
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)
{
StreamReader reader = new StreamReader(response.GetResponseStream());
st = reader.ReadToEnd();
}
return st;
}
___and please tell me how could i access the CSV file created.
... View more