The Community is hosting an End of Summer sweepstakes! Participants must complete tasks to earn tickets that will enter them with a chance to win a free year of Constant Contact and other great prizes!*
*No Purchase Necessary. For Official Rules, visit here. Constant Contact’s End of Summer 2020 Sweepstakes ends on October, 20, 2020 at 11:50 PM EST.

IE dying on request.GetResponse()

Highlighted
Occasional Organizer

IE dying on request.GetResponse()

I'm having an issue where the following code is working perfect in Chrome and FF but is dying on the bold/italic line in IE.  No error is thrown that I can tell, I have a try catch block that is printing to a text file any errors that are thrown.   The address variable is "https://api.constantcontact.com/ws/customers/[username]/contacts.  The contentType is "application/atom+xml".  The requestMethod is "POST".  The data is XML as shown below the code.  One thing I feel I should mention is that the username is an email address.  I'm assuming that this should be URL encoded. 

 

Any help would be appreciated.

 

            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(address);
            request.Credentials = CreateCredentialCache(address, authenticationData);
            request.Method = requestMethod;
            request.ContentType = contentType;
            request.PreAuthenticate = true;
            request.ContentLength = data.Length;
            Stream stream = request.GetRequestStream();
            stream.Write(data, 0, data.Length);
            Stream responseStream = Stream.Null;
            try
            {
 HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                Console.WriteLine(String.Format(CultureInfo.InvariantCulture,
                                                "Method {0}, response description: {1}", request.Method,
                                                response.StatusDescription));

                if (response.StatusCode == HttpStatusCode.NoContent)
                {
                    return Stream.Null;
                }
                responseStream = response.GetResponseStream();
                MemoryStream memoryStream = ReadResponseStream(responseStream);
                return memoryStream;
            }
            catch (Exception ex)
            {
                Logging.LogError("GetResponseStream: " + ex.Message);
            }
            finally
            {
                stream.Close();
                responseStream.Close();
            }
            return Stream.Null;

 

 

<entry xmlns="http://www.w3.org/2005/Atom">
	<title type="text"></title>
	<updated>2008-07-23T14:21:06.407Z</updated>
	<author></author>
	<id>data:,none</id>
	<summary type="text">Contact</summary>
	<content type="application/vnd.ctct+xml">
		<Contact xmlns="http://ws.constantcontact.com/ns/1.0/">
			<EmailAddress>email@email.com</EmailAddress>
			<FirstName>s</FirstName>
			<MiddleName></MiddleName>
			<LastName>j</LastName>
			<HomePhone>7</HomePhone>
			<Addr1></Addr1>
			<Addr2></Addr2>
			<Addr3></Addr3>
			<City></City>
			<StateCode></StateCode>
			<StateName></StateName>
			<PostalCode></PostalCode>
			<SubPostalCode></SubPostalCode>
			<CountryCode></CountryCode>
			<CompanyName>m</CompanyName>
			<JobTitle>i</JobTitle>
			<WorkPhone></WorkPhone>
			<EmailType>HTML</EmailType>
			<OptInSource>ACTION_BY_CONTACT</OptInSource>
			<Note></Note>
			<CustomField1></CustomField1>
			<CustomField2></CustomField2>
			<CustomField3></CustomField3>
			<CustomField4></CustomField4>
			<CustomField5></CustomField5>
			<CustomField6></CustomField6>
			<CustomField7></CustomField7>
			<CustomField8></CustomField8>
			<CustomField9></CustomField9>
			<CustomField10></CustomField10>
			<CustomField11></CustomField11>
			<CustomField12></CustomField12>
			<CustomField13></CustomField13>
			<CustomField14></CustomField14>
			<CustomField15></CustomField15>
			<ContactLists>
				<ContactList id="https://api.constantcontact.com/ws/customers/[username]/lists/37"/>
				<ContactList id="https://api.constantcontact.com/ws/customers/[username]/lists/39"/>
			</ContactLists>
		</Contact>
	</content>
</entry>

 

 

Developer Portal

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

Visit Page

Constant Contact 2020 End of Summer Community Sweepstakes!

The Constant Contact User Community is hosting a sweepstakes. The more you participate, the more chances you have to win! Read on to learn more...

Read More
Featured