v2 API & header names

SOLVED
Go to solution
Member

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>

1 ACCEPTED SOLUTION
Member

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>

View solution in original post

2 REPLIES 2
Member

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>

View solution in original post

Hi @imru,

 

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
Developer Portal

View API documentation, code samples, get your API key.

Visit Page