Howdy folks. I'm new here, so please forgive me if this is somewhat of a basic question.
I am using the Ruby GEM constant_contact version 1.1.5 and am able to authenticate and query contacts. When I attempt to create a new contact I receive a 400 Bad Request. I've read that this means poorly structured XML, but since I don't have access to the wrapper XML, the only XML I control is this:
<Contact xmlns="http://ws.constantcontact.com/ns/1.0/">
<EmailAddress>valid@email.com</EmailAddress>
<OptInSource>ACTION_BY_CUSTOMER</OptInSource>
<ContactLists><ContactList id="http://api.constantcontact.com/ws/customers/wildobs/lists/1"/>
</ContactLists>
</Contact>
Failed with 400 Bad Request
Thanks in advance.
Hello,
I looked over your XML and I was able to add this XML into the complete XML that you need to post a contact, and it did work. However, if you are just using this XML it would give a 400 error.
While I am not very familiar with the Ruby GEM Constant Contact wrapper, I should be able to tell you why you are getting the 400 error if you are able to dump the full XML that it is returning in the wrapper somewhere, and paste it here entirely.
Because this is a third party wrapper, I would suggest also trying to contact the person that created it if you are not able to get the full XML.
Regards,
Thanks for looking. I assume I don't get a more detailed error message, and you don't get server logs, which is a shame. I guess you get requests for those frequently.
I contacted the Ruby GEM developer first, and he was unable to see a problem with the XML.
Yeah, I recognize this is only a subset of the true XML, and I do want to see waht the full XML is. I am trying to get inside the Ruby GEM (asking gent above & getting inside the code myself.)
That said, could it be anything to do with my set-up, i.e. that I have a default list as id 3? I've jsut removed list with id 1 (since I never used) but assume I cannot re-number my list to be 1. For some reason the lsit shows with an sort order of 2, even though no other lists exist. Can I change that?
<entry xmlns="http://www.w3.org/2005/Atom">
<title type="text"> </title>
<updated>2010-09-30T12:08:55Z</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/"><CustomField1>test111111</CustomField1><CustomField2>2113</CustomField2><LastName>Tester</LastName><EmailAddress>valid@email.com</EmailAddress><FirstName>Ted</FirstName><OptInSource>ACTION_BY_CUSTOMER</OptInSource><ContactLists><ContactList id="http://api.constantcontact.com/ws/customers/wildobs/lists/3"/></ContactLists></Contact>
</content>
</entry>
Hello,
The sort order of a list generally has more to do with how the list is displayed in the user interface, and doesn't really affect the API. When adding a contact to a list you would want to specify the ID from the ID node in the List XML.
It is possible to change the sort order of a list by doing a PUT to the list URI with updated list XML that has the new sort order.
Also, having the default list something other than one should not affect adding contacts. You do want to verify that the list you are adding to really is the correct ID, you can do a GET to the list URI "https://api.constantcontact.com/ws/customers/(USERNAME)/lists", and it will give you a list of all of your lists, with there correct list ID.
If you have any questions please let me know.
Regards,
Hi,
I did a post using that XML to my own account and it did succeed. I have a feeling that the issue may be because of the list ID. I would verify that the list ID is correct by doing a GET call on the list URI and seeing what the ID node says for that specific list.
Regards,
I've done that, and if I read this correctly (and please forgive the ruby speak) it sure looks like "3".
#<ConstantContact::List:0x104e42ac8 @attributes={"Name"=>"Active", "id"=>"http://api.constantcontact.com/ws/customers/wildobs/lists/active", "ShortName"=>"Active", "xmlns"=>"http://ws.constantcontact.com/ns/1.0/"}, @prefix_options={}>
#<ConstantContact::List:0x104e0dc60 @attributes={"Name"=>"Do Not Mail", "id"=>"http://api.constantcontact.com/ws/customers/wildobs/lists/do-not-mail", "ShortName"=>"Do Not Mail", "xmlns"=>"http://ws.constantcontact.com/ns/1.0/"}, @prefix_options={}>
#<ConstantContact::List:0x104e0d7b0 @attributes={"Name"=>"Removed", "id"=>"http://api.constantcontact.com/ws/customers/wildobs/lists/removed", "ShortName"=>"Removed", "xmlns"=>"http://ws.constantcontact.com/ns/1.0/"}, @prefix_options={}>
#<ConstantContact::List:0x104e0c7e8 @attributes={"Name"=>"Wild Observations Newsletter", "Members"=>#<ConstantContact::List::Members:0x104e09520 @attributes={"id"=>"http://api.constantcontact.com/ws/customers/wildobs/lists/3/members"}, @prefix_options={}>, "id"=>"http://api.constantcontact.com/ws/customers/wildobs/lists/3", "DisplayOnSignup"=>"Yes", "ContactCount"=>"2074", "SortOrder"=>"2", "ShortName"=>"Wild Observations Newslet...", "OptInDefault"=>"true", "xmlns"=>"http://ws.constantcontact.com/ns/1.0/"}, @prefix_options={}>
Hi,
I have verified that the XML that you gave me, and the list id that you have, works without any issue.
While I am not a Ruby developer, we are going to try to do some testing with the Ruby Constant Contact wrapper to verify that it is working on our end, or to see if we can recreate the issue that you are having. Is it possible for you to send us the code that you are using to the Webservices Support team.
Regards,
... and I don't know if that is due to me changing things as I attempt to debug, or what. Do you get access to your API server logs? Does it log 500 errors?
Hi,
We experienced an issue with our servers from 3:22 PM to 3:38 PM Eastern Time. If you had received the 500 errors between that time that was more than likely the reason. Our ops team was able to successfully correct the problem and you should no longer be getting 500 errors.
Regards,
Thanks for all your help/communications Ben, but unfortunately I am getting 500 for everything still (3:51 eastern time.)
Hi,
It does appear that we are still running into some lingering issues. I apologize for the inconvenience for this and our engineers are alerted of this problem.
I will update this post once the issues have been completely resolved.
Regards,
Hello,
I apologize for the delay, but the servers are now back online and should be working. Please let me know if you are experiencing any further issues.
Regards,
Ben,
Thanks for all your help and communications today. The good news is that my problem has gone away. The less good news that is since I took the CC API server outage to upgrade my local Ruby on Rails environment (including a painful MySQL upgrade on Mac) I don't know if the problem was in the Rails stack, or inexplicably relate to the CC API server issues. That said, my money is on the rails upgrade.
Thanks.
P.S. The CC API servers most certainly need to respond w/ diagnostic error messges and/or log failure messages to a log each developer can review. Just my tuppence. That said, w/o them we get to me you so there is an up side. :)