server 500 error when adding new contact

Occasional Participant

server 500 error when adding new contact

I'm using the C# example for adding a contact as a go-by. The example you provided runs well. I've tried to make my own stripped down version, and I'm currently getting a server 500 error when I post.

I may be looking in the wrong place, but when I compare

 

 the data string posted by the example code:

<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>t16@t.com</EmailAddress><FirstName>asdflj</FirstName><MiddleName>sdf</MiddleName><LastName>sdfk</LastName><HomePhone>asdfljk</HomePhone><Addr1>sdflj</Addr1><Addr2></Addr2><Addr3></Addr3><City>asdflj</City><StateCode>TN</StateCode><StateName>Tennessee</StateName><PostalCode>sdf</PostalCode><SubPostalCode></SubPostalCode><CountryCode>us</CountryCode><CompanyName></CompanyName><JobTitle></JobTitle><WorkPhone></WorkPhone><EmailType>HTML</EmailType><OptInSource>ACTION_BY_CUSTOMER</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="http://api.constantcontact.com/ws/customers/dcarpenterwuot91.9fm/lists/2"/></ContactLists></Contact></content></entry>

 

to mine:

<entry xmlns="http://www.w3.org/2005/Atom"><id>data:,none</id><title type="text">Contact: add test</title><updated>2012-01-12T01:29:06.096Z</updated><author> </author><summary type="text">Contact</summary> <content type="application/vnd.ctct+xml"><Contact xmlns=" http://ws.constantcontact.com/ns/1.0/"><EmailAddress>z3@t.com</EmailAddress><FirstName>asdflk</FirstName><MiddleName>sdfj</MiddleName><LastName>selj</LastName><HomePhone></HomePhone><Addr1>sdfj</Addr1><Addr2></Addr2><Addr3></Addr3><City>asdfl</City><StateCode>TN</StateCode><StateName>Tennessee</StateName><PostalCode>sfd</PostalCode><SubPostalCode></SubPostalCode><CountryCode>us</CountryCode><CompanyName></CompanyName><JobTitle></JobTitle><WorkPhone></WorkPhone><EmailType>HTML</EmailType><OptInSource>ACTION_BY_CUSTOMER</OptInSource><ContactLists><ContactList id="http://api.constantcontact.com/ws/customers/dcarpenterwuot91.9fm/lists/2"/></ContactLists></Contact></content></entry>

 

I don't see anything grossly wrong. The list id in each post is the same.  I think the 500 means that something crashed at ConstantContact.

 

Any suggestions would be welcome.

4 REPLIES 4
Employee

Hey,

 

If you could please try submitting that to our service via a RESTclient and see if you get the same results it would help us delimit the issue.  You can download the RESTclient here.  Once you download it and set it up you awnt to submit your XML that you listed to the appropriate collection.  If you are creating a contact you would use the URI of

https://api.constantcontact.com/ws/customers/{username}/contacts

 or if you are adding it to a new list

https://api.constantcontact.com/ws/customers/{username}/contacts/{ID}

If you still get a 500 error please save request and response through the file menu and send it to webservices@constantcontact.com  From there we can do more troubleshooting against your account and see what exactly is happening.  

Ryan Davis
Quality Engineer
Occasional Participant

thanks, I haven't quite figured out the java client yet - am getting a different error that is probably my input related

When using the XML you posted on the forums, I was able to create a Contact on my account once fixing the following line:

 

<Contact xmlns=" http://ws.constantcontact.com/ns/1.0/">

 

In the XML you pasted, though this may or may not be a typo, you have a space between the opening " and the http portion of the namespace URL.  This would cause a 500 error as an error is thrown when we try to retrieve the namespace document. 

 

If that doesn't fix your problem, please email your XML as a .xml or .txt file attachement to webservices@constantcontact.com to avoid copy/paste errors.  This way we can look at your exact XML.

Dave Berard
Senior Product Manager, Constant Contact
Occasional Participant

great, thanks Dave - I had got it working this AM by taking what the example program generated and using that as the basis of my XML literal string. The following works, and I suspected that I had some picky error in mine. Sounds like you found it (or one of them!). Thanks much.

 

Working literal string:

// trimmed down and workingstring strData3 = @"

<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>z8@t.com</EmailAddress>

<FirstName>qqqfirst</FirstName>

<LastName>qqqlast</LastName>

<Addr1>qqqaddr</Addr1>

<City>qqqcity</City>

<StateName>Tennessee</StateName>

<PostalCode>qqqzip</PostalCode>

<CountryCode>us</CountryCode>

<EmailType>HTML</EmailType>

<OptInSource>ACTION_BY_CUSTOMER</OptInSource>

<ContactLists><ContactList id=""http://api.constantcontact.com/ws/customers/dcarpenterwuot91.9fm/lists/2""/></ContactLists>

</Contact></content></entry>

";

 

 

// working code - I realize that it depends on some routines from the ConstantContact C# example

voidhandle_PostString()

{

 

string PostToHere = "https://api.constantcontact.com/ws/customers/YOUR_ID/contacts";

 

// PostToHere = "http://127.0.0.1:8181"; // Fiddler testingstring apiKey = ConfigurationManager.AppSettings["ApiKey"];

 

string username = ConfigurationManager.AppSettings["username"];

 

string password = ConfigurationManager.AppSettings["password"];

 

AuthenticationData authenticationData = newAuthenticationData(apiKey, username, password);

 

stringstrPostLiteralString = strData3;

 

Stream stream = Stream.Null;

 

try

{

// post the Atom entry at specified Uri and save the response streamUri AccountContactsUri = newUri(PostToHere);

 

System.Diagnostics.

Debug.Print(strData);

stream =

Utility.PostInformation(authenticationData, AccountContactsUri, strPostLiteralString);

 

StreamReader reader = newStreamReader(stream);

 

stringtext = reader.ReadToEnd();

txtResponse.Text = text;

}

catch (Exceptione)

{

System.Diagnostics.

Debug.Print(e.ToString());

txtResponse.Text = e.ToString(); // txtResponse is a textbox

txtResponse.Text +=

"****************************";

txtResponse.Text += strData;

}

 

}

 

 

 

Developer Portal

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

Visit Page