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, 20, 2020 at 11:50 PM EST.

Bulk Activities - Export Contacts Endpoint - error 400 Bad Request

Highlighted
Occasional Contributor

Bulk Activities - Export Contacts Endpoint - error 400 Bad Request

Hi I've been trying to export the contacts in a specified list to a CSV file. I'm able to retrieve lists and campaigns with my API Key and access token (I'm using a trial account as I'm developing for another company).

 

I'm unable to get a 201 response only getting an Error 400 Bad Request response

 

I've been using the documentation at

http://developer.constantcontact.com/docs/bulk_activities_api/bulk-activities-export-contacts.html?m...

 

My uri is (api key and token have been obfuscated) ;

 https://api.constantcontact.com/v2/activities/exportcontacts?api_key=nnnnnnnnnnnnnn&access_token=nnn...

 

The contenttype is "application/json"

 

Initially I tried this JSON ;

{ "file_type": "CSV","sort_by": "EMAIL_ADDRESS","export_date_added": true,"export_added_by": true,"lists": [ "1300039208" ],"column_names": [ "Email","First Name","Last Name","Job Title","Company Name","Work Phone","Home Phone","Address Line 1","Address Line 2","Address Line 3","City","State","Country", "Zip/Postal Code","Custom field 1","Custom field 2","Custom field 3","Custom field 4","Custom field 5","Custom field 6","Custom field 7","Custom field 8","Custom field 9","Custom field 10","Custom field 11","Custom field 12","Custom field 13","Custom field 14","Custom field 15", ] }

 

Then I modified the JSON to the following;

 

{ "file_type": "CSV","sort_by": "EMAIL_ADDRESS","export_date_added": true,"export_added_by": true,"lists": [ "1300039208" ],"column_names": [ "Email","First Name","Last Name","Job Title","Company Name","Work Phone","Home Phone","Address Line 1","Address Line 2","Address Line 3","City","State","Country", "Zip/Postal Code" ] }

 

Any thoughts on what may be the issue?

Thanks

Rohan

 

 

5 REPLIES 5
Highlighted
Employee

Re: Bulk Activities - Export Contacts Endpoint - error 400 Bad Request

Hi Rohan,

 

Sorry to hear about the issue. After some troubleshooting, I found that your second JSON payload goes through if you replace "State" with "US State/CA Province". I'd suggest that workaround for the time being. I'm opening a defect on our side, since this should (and used to) work with "State" in the payload.

 

Best Regards,

Shannon Wallace

Partner API Support Engineer

Highlighted
Occasional Contributor

Re: Bulk Activities - Export Contacts Endpoint - error 400 Bad Request

Thank you very much. 

Rohan

Highlighted
Occasional Contributor

Re: Bulk Activities - Export Contacts Endpoint - error 400 Bad Request

Hi There,

I've changed the code as per your suggestion. The response is no longer errorcode 400 - however, I'm just getting a response of "Received HTTP Created" - I'm not getting any information regarding the file or the status of the request as per the example response in the documentation

Thanks

Rohan

Highlighted
Employee

Re: Bulk Activities - Export Contacts Endpoint - error 400 Bad Request

Hi Rohan,

 

Our API response is broken up into 2 parts: the response header, which contains the "201 Created" text, and the response message body, which contains JSON that gives you the JSON response you see on our documentation page.

 

If you capture and print the response message body, you'll see what you're looking for. I confirmed this is working, and I get this reponse:

 

Response Header:

201 Created

 

Response Message Body:

 

{
"id": "92c93260-da31-11e5-9e40-d4ae5292c4dd",
"type": "EXPORT_CONTACTS",
"error_count": 0,
"contact_count": 0
}

 

I hope that helps. If you want to see the JSON response, you need to add a bit of code that prints the response body (or make the call from a rest client so that you can see the full response).

 

Best Regards,

Shannon Wallace

Partner API Support Engineer

Highlighted
Occasional Contributor

Re: Bulk Activities - Export Contacts Endpoint - error 400 Bad Request

Hi Shannon,

 

Thanks for your response. 

 

I'm still not having any luck with this. I've tried a number of things but still get the same response. The rest client component does capture any response.

 

Something in my request is obviously not working, although I am using the same rest client and successfully retrieving JSON on Campaigns, Lists and List Memberships with it. I'm not too sure what else I can do in forming my http request.

 

I'll have to think of a different approach for my client's automation.

 

Thanks

Rohan

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