- Constant Contact Community
- :
- Developer Community
- :
- Authentication and Access (ie. 401 errors!)
- :
- 400 error common atom issues
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
400 error common atom issues
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
02-12-2010 07:36 PM
Hello,
I'm getting these 400 errors saying that my atom stuff is a no go. I have verified the structure, and that I'm using my default atom nodes. Here is my action. Anybody got any clues?
$newEmail = $_POST;
$date = date("Y-m-d\TH:i:s");
$theXml = <<<THE__XML
<entry xmlns="http://www.w3.org/2005/Atom">
<title type="text">Contact Stuff</title>
<updated>$date</updated>
<author></author>
<id>http://api.constantcontact.com/ws/customers/us
<summary type="text">Contact</summary>
<content type="application/vnd.ctct+xml">
<Contact xmlns="http://ws.constantcontact.com/ns/1.0/" id="http://api.constantcontact.com/ws/customers/us
<EmailAddress>$newEmail</EmailAddress>
<OptInSource>ACTION_BY_CONTACT</OptInSource>
<ContactLists>
<ContactList id="http://api.constantcontact.com/ws/customers/us
</ContactLists>
</Contact>
</content>
</entry>
THE__XML;
$ch = curl_init();
$UN = "username";
$PW = "password";
$Key = "blahblahblah";
$userNamePassword = $Key . '%' . $UN . ':' . $PW;
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, $userNamePassword);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS , $theXML);
curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type:application/atom+xml"));
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// set the url to fetch
curl_setopt($ch, CURLOPT_URL, 'https://api.constantcontact.com/ws/customers/user
$content = curl_exec($ch);
// remember to always close the session and free all resources
curl_close($ch);
echo $content;
errors in the atom section
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
02-13-2010 11:23 AM
Hi, I looked at your posting because I was getting similar errors. In my case it was because I was trying to fetch a contact using a POST (should have used a GET, stupid transcribing error on my part). In your case I see one big problem. In your line:
curl_setopt($ch, CURLOPT_URL, 'https://api.constantcontact.com/ws/customers/user
you should be using the actual user-name, not the string 'username'.
--- Cliff Janson, independent consultant (http://comparehybridcars.net/cliff-janson.html)
No Go on that one
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
02-15-2010 06:04 PM
Hi Cliff,
Well, I'm not trying to fetch a contact, I'm trying to add a contact and that, I think is a POST. Also, i have username because i didnt want to give out the real user. thanks for your help though, any other ideas? Anybody from CC have some input?
:)
Josh
I compared your XML with what
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
02-15-2010 06:13 PM
I compared your XML with what we recommend when creating a new contact, shown in http://developer.constantcontact.com/doc/manageCon
1. Please double check your date format to make sure it matches the format used in the example XML, including milliseconds and "Z" at the end
2. Please change the value of <id> tag to what's used in the example., which is "data:,none".
The XML that's listed in the above link is what works when you try to create a contact. You should only have to change the values inside <content> tag and shouldn't have to touch anything else.
Still nothing
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
02-22-2010 09:38 AM
Ok, made the changes you said may be causing the problem and still nothing. Here is an output of the xml I'm sending with the response right below.
<entry xmlns="http://www.w3.org/2005/Atom">
<title type="text">Oread Contact</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>test_100@example.com</EmailAddress>
<OptInSource>ACTION_BY_CONTACT</OptInSource>
<ContactLists>
<ContactList id="http://api.constantcontact.com/ws/customers/Robinski66/lists/13" />
</ContactLists>
</Contact>
</content>
</entry>
Error 400: The request contains errors in the common Atom sections, which lie outside <entry> or <Content>, such as <feed>, <id>, <author> or <updated>.
A few other ideas
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
02-23-2010 12:28 PM
I looked at my code that adds a contact (and which is working) and noticed a couple things:
In my curl options, I am using two that you are not:
curl_setopt($session, CURLOPT_FOLLOWLOCATION ,1);
curl_setopt($session, CURLOPT_SSL_VERIFYPEER, 0);
Might these matter to your error? Don't know.
Also in building my XML, a few other minor differences:
- I am using <OptInSource>ACTION_BY_CUSTOMER</OptInSource>
- My <title> node is empty: <title type="text"> </title>
- I am not supplying ms in the time in the <updated> node, I use PHP date('Y-m-d\TH:i:s\Z')
- I am supplying first and last name nodes in addition to email
Otherwise, I am doing exactly what you are.
still no go
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
02-25-2010 03:36 PM
Thanks for the ideas... tried making those changes too, and still nothing..... Anybody work at Constant Contact? Any developers that might have a second to help me out with this?
After looking at your code it
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
02-25-2010 03:57 PM
After looking at your code it looks as though your variable containing the XML is set as $theXml however in the cURL request you a referencing $theXML.
This, along with the changes that JSJ suggested should resolve your issue.
Dan H
Support Engineer, Constant Contact


