Hi,
I am not sure if anyone here is familiar with Meteor, but that is what I am using to build my application, there is a http package, and you can see it's api here. I was able to successfully add a Contact in the API tester page, but when I use my code I get a 400 response saying. I am thinking it has something to do with the data option, but I am not quite sure what to try instead.
{ [Error: failed [400] [{"error_key":"query.param.invalid","error_message":"The query parameter status is not supported."},{"error_key":"query.param.invalid","error_message":"The query parameter limit is not supported."}]]
Here is my code
var data = { "addresses": [ { "address_type": "BUSINESS", "city": "Belleville", "country_code": "CA", "line1": "47 Shawmut Ave.", "line2": "Suite 404", "postal_code": "K8b 5W6", "state_code": "ON" } ], "lists": [ { "id": "1395617465" } ], "cell_phone": "555-555-5555", "company_name": "System Optimzations", "confirmed": false, "email_addresses": [ { "email_address": "username2@example.com" } ], "fax": "555-555-5555", "first_name": "Ronald", "home_phone": "555-555-5555", "job_title": "Systems Analyst 3", "last_name": "Martone", "prefix_name": "Mr.", "work_phone": "555-555-5555" }; HTTP.post('https://api.constantcontact.com/v2/contacts?status=ALL&limit=50&api_key=<random-key>', { headers: { 'Authorization': 'Bearer <random-token>', 'Content-Type': 'application/json' }, data: JSON.stringify(data) }, function (error, response) { if ( error ) { console.log( error ); } else { console.log(response); } });
Solved! Go to Solution.
Hello @AndersK81,
Thank you for reaching out to Constant Contact's API Support.
When making a post you do not need some of the parameters that you are including in your POST URL and I believe that is the issue that is causing your error.
You are posting to this URL.
https://api.constantcontact.com/v2/contacts?status=ALL&limit=50&api_key=<random-key>
Why don't you try to POST to this one.
https://api.constantcontact.com/v2/contacts?api_key=<random-key>
The only other parameter you might consider using in a POST URL would be the action_by parameter. You can read about that here. https://developer.constantcontact.com/docs/contacts-api/contacts-collection.html?method=POST
Hello @AndersK81,
Thank you for reaching out to Constant Contact's API Support.
When making a post you do not need some of the parameters that you are including in your POST URL and I believe that is the issue that is causing your error.
You are posting to this URL.
https://api.constantcontact.com/v2/contacts?status=ALL&limit=50&api_key=<random-key>
Why don't you try to POST to this one.
https://api.constantcontact.com/v2/contacts?api_key=<random-key>
The only other parameter you might consider using in a POST URL would be the action_by parameter. You can read about that here. https://developer.constantcontact.com/docs/contacts-api/contacts-collection.html?method=POST