0
votes

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
Try it without a trailing slash on members. Also make sure the account_id you're using is valid. Their documentation is a bit confusing with how they use # since it is valid in a URL, however the request you're trying to make is shown without a trailing slash (GET /#account_id/members)Charles
Tried it without trailing slash, still the same. Also I think i have the right urluser747291
I think the public and private api key needs to be sent as a header and not form fields. helpx.adobe.com/coldfusion/cfml-reference/coldfusion-tags/…Randy Johnson
If you look at their main page they have some examples. This one is PHP however, they're using api.e2ma.net instead of app.e2ma.net. Here is their example: $url = "https://api.e2ma.net/".$account_id."/members/add";.Charles
Yes lol, using the correct url will definitely help. I missed that on first glance. Now you should be able to use the header to do the basic authRandy Johnson

1 Answers

3
votes

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.