cancel
Showing results for 
Search instead for 
Did you mean: 

How to add parameters to contacts request

SOLVED
Occasional Contributor

How to add parameters to contacts request

I am trying to POST to this URL:

https://api.constantcontact.com/v2/contacts

 

...to check for the existence of a contact before adding it. The script in this case is written in Classic ASP. The POST variables are added like this:

 

inetRequest.AddParam "APIKEY", "xxx"
inetRequest.AddParam "ACCESS_TOKEN", "yyy"
inetRequest.AddParam "action_by", "ACTION_BY_OWNER"
inetRequest.AddParam "email", "<email@domain.com>"

 

...but with my API Key and Access Token, of course. When I test this, I get:

 

[{
	"error_key":"mashery.not.authorized.inactive",
	"error_message":"The Mashery account associated with this request is not active, or an invalid API key was used."
}]

 

I assume one of the parameter names or something about the syntax is not correct?

 

Thank you.

3 REPLIES
Moderator

Re: How to add parameters to contacts request

Hello,

Thank you for reaching out to Constant Contact API Support.

That error means that the API Key you are using is invalid, or the email address on the developer account associated with it has not been verified.

The most common cause for this error is using an access token where the API Key should be, and vice versa. So first I would check that you are using the correct API Key. If you are using the correct API Key, please send us an email at webservices@constantcontact.com with your API Key, Access Token, and Email Address you are testing with so we can try to replicate, and identify why you are seeing this error.

Also, you mentioned that you are using POST to see if a contact exists before adding it. The best practice when adding contacts is to first do a GET for the email address to see if it exists already. If it does not, then you can POST a new contact with that address. If it does already exist, you cannot POST the address as a new contact, however you can use a PUT to update it.

Please let me know if you have any other questions!

Sincerely,
David B.
Tier II API Support Engineer

Occasional Contributor

Re: How to add parameters to contacts request

I modified my parameter code slightly, to this:

 

inetRequest.AddParam "api_key", "xxx"
inetRequest.AddParam "access_token", "yyy"
inetRequest.AddParam "action_by", "ACTION_BY_OWNER"
inetRequest.AddParam "email", "name@domain.com"

 

Now I get a different message:

[{"error_key":"http.header.content_type.invalid","error_message":"Invalid content type. API only supports application/json."}]

 

So perhaps this means my authentication is at least working? Next, it wants JSON data only. I am having a really hard time finding any examples of what a JSON request looks like. Where is there a simple JSON request example?

 

All I want to do for right now is check to see if an email is already in Contacts for this account. To do that, I setup a JSON request with a single parameter: "email", is that correct?

 

Also, when I say POST I'm talking about the POST mechanism from our server to the API server. Like POST vs. GET requests. Not talking about commands that Constant Contact understands.

 

Thanks.

Moderator

Re: How to add parameters to contacts request

Hello,

 



@clarisam4 wrote:

 

All I want to do for right now is check to see if an email is already in Contacts for this account. To do that, I setup a JSON request with a single parameter: "email", is that correct?


You would do an HTTP GET request with the parameter of email. http://developer.constantcontact.com/docs/contacts-api/contacts-collection.html?method=GET

 

 


Also, when I say POST I'm talking about the POST mechanism from our server to the API server. Like POST vs. GET requests. Not talking about commands that Constant Contact understands.


Correct. This is also what we are referring to when our documentation uses GET, POST, PUT, etc. You would make a GET request, not a POST, to the endpoint with no body payload. If the contact exists, the response will be a JSON object. See the example response at the earlier link to see what this will look like. If the contact does not exist you will get back a Not Found response.

 

 



it wants JSON data only. I am having a really hard time finding any examples of what a JSON request looks like. Where is there a simple JSON request example?

There is an example body in our documentation for each endpoint. If you are creating a brand new contact, you can see that here: http://developer.constantcontact.com/docs/contacts-api/contacts-collection.html?method=POST#example-...

 

Regards,
David B.
Tier II API Support Engineer

 

Still need help?
You can post a new message in the Community or find us on Twitter Mon-Fri 8am - 8pm ET. We've got real people waiting to help you out. Click below to start a conversation!