Timeout Errors on Opting Out Contacts

Regular Participant

Timeout Errors on Opting Out Contacts

Hello,

 

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)

        {

            try

            {

                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)

                {

                    Console.WriteLine(((HttpWebResponse)response).StatusDescription);

                    //Console.Read();

                    Stream dataStream = response.GetResponseStream();

                    StreamReader reader = new StreamReader(dataStream);

                    string responseFromServer = reader.ReadToEnd();

                    // Display the content.

                    Console.WriteLine(responseFromServer);

                    //Console.ReadLine();

                    // Clean up the streams.

                    reader.Close();

                    dataStream.Close();

                    response.Close();

                    //Console.ReadLine();

                    StringBuilder sb = new StringBuilder();

                    sb.Append(responseFromServer);

                    //xmlDoc.LoadXml(sb.ToString());

                }

            }

            catch (Exception ex)

            {

                Console.WriteLine(ex);

                Console.ReadLine();

            }

        }

 

Thanks!

 

2 REPLIES 2
Employee

Hi,

 

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:

 

request.Close();

 

Best Regards,

Shannon W.

API Support Specialist

Regular Participant

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!

Developer Portal

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

Visit Page