I am trying to create a new list.
I am POSTing the XML to https://api.constantcontact.com/ws/customers/{account}/lists. Where {account} is my user account name.
The XML is:
<?xml version="1.0" encoding="UTF-8"?>
<entry xmlns="http://www.w3.org/2005/Atom">\r\n
<id>data:,none</id>\r\n
<title type="text"/>\r\n
<author />\r\n
<updated>2010-07-12T14:02:17Z</updated>\r\n
<content type="application/vnd.ctct+xml">\r\n
<ContactList xmlns="http://ws.constantcontact.com/ns/1.0/">\r\n
<Name>New</Name>\r\n
</ContactList>\r\n
</content>\r\n
</entry>\r\n
I do not get any response nor does the new list get created. I do not have any problems GETing the current list.
Does any one know what might be wrong and is there a way for the Constact Contact server admin to look at their logs to see what is being received and what might need to be adjusted?
I am using PHP with the following method similar to one provided as samples:
function CallServer( $uri, $method, $args )
{
$data = "";
$url = sprintf( "%s/ws/customers/%s/%s", $this->host, $this->account, $uri );
$auth = sprintf( "%s%s%s:%s", CRM_CONSTANT_CONTACT_KEY, '%', $this->account, $this->password );
$ch = curl_init();
printf( "url <br>", $url );
if( $method == "GET" )
{
if( $args != "" )$url .= '?' . $args;
curl_setopt( $ch, CURLOPT_HTTPGET, true );
}
else if( $method == "POST" )
{
curl_setopt( $ch, CURLOPT_POST, true );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $args );
}
else if( $method == "PUT" )
{
curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, "PUT" );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $args );
}
else if( $method == "DELETE" )
{
curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, "DELETE" );
}
curl_setopt( $ch, CURLOPT_URL, $url );
curl_setopt( $ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
curl_setopt( $ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC );
curl_setopt( $ch, CURLOPT_USERPWD, $auth );
curl_setopt( $ch, CURLOPT_HEADER, 0);
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
//curl_setopt( $ch, CURLOPT_HTTPHEADER, array( "Content-Type:application/atom+xml" ) );
curl_setopt( $ch, CURLOPT_HTTPHEADER, array( "Content-Type:application/atom+xml", 'Content-Length: ' . strlen( $args ) ) );
curl_setopt( $ch, CURLOPT_FAILONERROR, 1);
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, 0);
$data = curl_exec( $ch ); // reply
curl_close( $ch );
flush();
return $data;
}
John Tegen
OnSite Connex
Content type needed to be
<content type="application/vnd.atom+xml">
John Tegen
OnSite Connex
I apologize for not responding sooner, I was just beginning to look at your code, but I am glad that you were able to resolve the 400 error that you were receiving.
For more information regarding list creation, I would recommend taking a look at Creating a List, as this will show example of the XML needed to create a list in your account.
Please let us know if you have any further questions.
David J