Connect to remote API using ColdFusion cfhttp

4.4k views Asked by At

I am trying to connect to the emma api using ColdFusion. Using the below code. Trying to get a listing of all members in an account as per api docs doing the below. I keep getting status code of 404 on the below call. Any ideas on what I am missing here?

<cfset account_id= '123'/>
<cfset public_key = 'abc'/>
<cfset private_key = 'xyz' /> 
<cfset the_url = 'https://app.e2ma.net/#account_id#/members/' />

<cfhttp url="#the_url#" method="get" result="Results" timeout="999">
      <cfhttpparam type="header" name="Content-Type" value="application/x-www-form-urlencoded" />
      <cfhttpparam type="header" name="Accept" value="application/json"  />
      <cfhttpparam type="header" name="public_api_key" value="#public_key#" >
      <cfhttpparam type="header" name="private_api_key" value="#private_key#" >
</cfhttp>
<cfdump var="#Results#"/> 

Here are the results of the cfdump:

cfdump of results variable

1

There are 1 answers

1
Charles On BEST ANSWER

It looks like you're using the wrong endpoint. In their documentation they say the following:

The endpoint for all of our API calls is https://api.e2ma.net/

In your code you're using app.e2ma.net, this should be api.e2ma.net instead.

Also the path for the URL you're requesting doesn't include a trailing slash in their documentation (GET /#account_id/members is what they have). You may also want to update that.