Hi Nick, Actually I rewrote it in C#, which could be a source of the problem. I was unable to find the C# equivalent of casting a WebRequest to an HttpWebRequest: The VB version was this: Dim request As HttpWebRequest = TryCast(WebRequest.Create(address), HttpWebRequest) My C# version is this: WebRequest request = WebRequest.Create(address); Effectively I'm using a WebRequest object instead of a HttpWebRequest object. I wouldn't be surprised if that causes an issue. Other than that, the rest of the code ported over to C# without a problem. Here's the whole thing, and thank you for any help: string CCusername = "nationalwestern";
string CCpassword = "PASSWORD REMOVED";
string CCuri = "https://api.constantcontact.com/ws/customers/" + CCusername + "/activities";
string CClistUri = "https://api.constantcontact.com/ws/customers/" + CCusername + "lists/2";
string CCAPIKEY = "API KEY HERE";
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,Last Name" + "\n"), Encoding.UTF8));
data.Append(HttpUtility.UrlEncode((email + "," + first_name + "," + last_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();
} FYI, I intentionally removed the account password and the API key data from the code.
... View more