I am receiving time out errors trying to opt out contacts. I am using a basic HTTP DELETE method for opting out contacts in certain bounce categories from the last email sent. This used to work fine. I’ve tried this two days in a row, and I get the same result: my application gets a list of the contacts I want to opt-out, and seems to opt-out the first two fine (NoContent status code is returned); however, trying to opt-out the third contact returns time outs. The contact I was trying to delete this time was https://api.constantcontact.com/ws/customers/abdataclassaction/contacts/8826. When I view this contact in a web browser, it seems to be a valid contact. Since I’ve received timeout errors on the 3rd contact two days in a row, I doubt this is due to a certain contact.
Any idea what could be causing this?
My code used is:
deleteData(mApiUsername, mPassword, null, requestCall);
private static void deleteData(string apiUsername, string password, XmlDocument xmlDoc, string requestCall)
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(requestCall);
request.Method = "DELETE";
request.ContentType = "application/atom+xml";
request.Credentials = new NetworkCredential(apiUsername, password);
HttpWebResponse response = (HttpWebResponse)request.GetResponse(); //The third requestCall times out here…
if (response.StatusCode == HttpStatusCode.OK)
Stream dataStream = response.GetResponseStream();
StreamReader reader = new StreamReader(dataStream);
string responseFromServer = reader.ReadToEnd();
// Display the content.
// Clean up the streams.
StringBuilder sb = new StringBuilder();
catch (Exception ex)
I'm sure this is due to a stream not getting closed. We had to modify one of our wrappers because it was leaving streams open and causing a timeout error upon updating the 3rd contact as well. I see you're closing your response stream, perhaps all you need is:
API Support Specialist
That fixed it. My HTTP deleteData was only running response.Close() if the status code returned was OK, which didn't make sense. Using response.Close() fixed it. Thanks!