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 16th, 2020 at 11:59 PM EST.

Receiving "Bad request" response with previously-working code.

SOLVED
Go to solution
Highlighted
Regular Visitor

Receiving "Bad request" response with previously-working code.

Hello,

 

I'm using PHP v2 library for my application (emails synchronization from commercial CMS to CC account)
https://github.com/constantcontact/php-sdk

Everything working good a week ago (13.04.2015). I'm providing existing tokens, API keys etc. But now (today) when I continued wtih the development I've got the response: 
Uncaught exception 'Ctct\Exceptions\CtctException' with message '[{"error_key":"http.status.bad_request","error_message":"Bad request."}]' in C:\xampp\htdocs\...\Ctct\Util\RestClient.php on line 95

 

I'm creating an activity to import all the active users in a following manner:

====

$cContact =  new ConstantContact(CCONT_APIKEY);

$exportObj = new ExportContacts(array("Active"));


$exportObj->column_names = array(
"Email", "First Name", "Last Name"
);
$exportObj->file_type = "CSV";
$exportObj->sort_by = "EMAIL_ADDRESS";
$exportObj->export_date_added = FALSE;
$exportObj->export_added_by = FALSE;
$jRes = $cContact->addExportContactsActivity(CCONT_ACCESS_TOKEN, $exportObj);
=====

The JSON string is sendind to ConstantContact server (post request field, sending via cUrl - see \Ctct\Util\RestClient.php - httpRequest method) is:

{"file_type":"CSV","sort_by":"EMAIL_ADDRESS","export_date_added":false,"export_added_by":false,"lists":["Active"],"column_names":["Email","First Name","Last Name"]}

 Please let me now if something wrong, what is the reason of bad request?

If the syntax of the JSON-encoded string was changed, please let me know, what are new requirements and how it could be fixed. Also for all the developers it would be nice to get appropriate fixes in PHP library.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Regular Visitor

Re: Receiving "Bad request" response with previously-working code.

I've finally found the solution for this particular case.

 

In development I used the following documentation:

https://developer.constantcontact.com/docs/bulk_activities_api/bulk-activities-export-contacts.html

You may find there in the section "Export system generated lists" following system-generated lists:

 

  • Active
  • Opted-out
  • Removed

So as a good developer I've used the names exactly the same way, as it is mentioned in the guide (yes, with "human-compatible" first capital letter). And till one moment everything worked fine for me and for my customers. But now, it seems the API handlers were upgraded on Constant Contact side. And I've got "Bad request".

But after a while I've played a bit with the exmaples and tried to ask for not "Active", but "active" system list. And it helped.

 

So for the "system lists" we may use only lowercased identifiers now, but this "trick", unfortunately not mentioned in the documentation yet.

View solution in original post

4 REPLIES 4
Highlighted
Regular Visitor

Re: Receiving "Bad request" response with previously-working code.

I've finally found the solution for this particular case.

 

In development I used the following documentation:

https://developer.constantcontact.com/docs/bulk_activities_api/bulk-activities-export-contacts.html

You may find there in the section "Export system generated lists" following system-generated lists:

 

  • Active
  • Opted-out
  • Removed

So as a good developer I've used the names exactly the same way, as it is mentioned in the guide (yes, with "human-compatible" first capital letter). And till one moment everything worked fine for me and for my customers. But now, it seems the API handlers were upgraded on Constant Contact side. And I've got "Bad request".

But after a while I've played a bit with the exmaples and tried to ask for not "Active", but "active" system list. And it helped.

 

So for the "system lists" we may use only lowercased identifiers now, but this "trick", unfortunately not mentioned in the documentation yet.

View solution in original post

Highlighted
Moderator

Re: Receiving "Bad request" response with previously-working code.

Hi Max, I've updated the documentation to show only lower case letters for the system generated lists. I'm wondering why this may have changed, as you stated that your code was working prior to April 13th? and will ask the team to look into this. 

 

Thanks for your contribution, and my apologies for the inconsistency between the docs and API behavior.

 

Regards,

Rich

Rich Marcucella
Sr. Technical Writer, Content Developer
Web Services Team
http://developer.constantcontact.com
Highlighted
Moderator

Re: Receiving "Bad request" response with previously-working code.

Hi Max,

 

The root cause of this change is a bug we introduced 2 releases ago, WS6327. We are in the process of scoping the changes required to fix the behavior back to being case-insensitive. Please refer to the Open Issues page for status and progress on this bug. 

Rich Marcucella
Sr. Technical Writer, Content Developer
Web Services Team
http://developer.constantcontact.com
Highlighted
Moderator

Re: Receiving "Bad request" response with previously-working code.

Wanted to update this thread that we have deployed a fix for this.  Issue should be resolved.  Thanks for reporting this defect!

Dave Berard
Senior Product Manager, Constant Contact
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