cancel
Showing results for 
Search instead for 
Did you mean: 

v2 API & header names

SOLVED
Highlighted
Occasional Advisor

v2 API & header names

Hello -

 

My app is in coldfusion so there aren't any wrappers to use.  I generate a token from the I/O docs and have my api key, but what are you expecting to be passed in the http header?  Or am I doing this incorrectly?

 

For example...

 

<cfhttp
url="https://api.constantcontact.com/v2/account/info?api_key=adhrawqfpbgpucj78qdg6d7e"
result="objGet">

<cfhttpparam
type="header"
name="username"
value="MY CC USERNAME"
/>

<cfhttpparam
type="header"
name="token"
value="GENERATED TOKEN"
/>

</cfhttp>

2 REPLIES
Occasional Advisor

Re: v2 API & header names

After a bunch of trial and error, I figured it out...for those who might still be using coldfusion (My app is still in the stone age, on coldfusion 8.01)..here's what you need.

 

name = Authorization

value = Bearer [TOKEN]

 

*Note:  You need a mashery account, API key, and token generated...also replace [APIKEY] with your api_key and [TOKEN] with your token (without square brackets)

 

<!--- Creatr a variable for the URL --->

<!---
API Key for CC, given by CC
--->
<cfset api_key = "api_key=[APIKEY]">

<!---
URL for API GET, without API Key
--->
<cfset uri = "https://api.constantcontact.com/v2/account/info?">

<!---
Full URI for GET
--->
<cfset fullURI= uri & api_key>


<!--- Make the Get Request --->
<cfhttp
url="#fullURI#"
method="GET"
charset="utf-8">

<cfhttpparam
name="Authorization"
type="header"
value="Bearer [TOKEN]"
/>

</cfhttp>

Moderator

Re: v2 API & header names

Hi @SteveP931,

 

Thank you for posting your work on this. We've had a few other Coldfusion users and I'm sure they will also be grateful.


Regards,
Jimmy D.
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!