json - 使用 ColdFusion cfhttp 连接到远程 API

标签 json coldfusion cfhttp

我正在尝试使用 ColdFusion 连接到 emma api。使用下面的代码。 Trying to get a listing of all members in an account按照 api 文档执行以下操作。我在下面的调用中不断收到 404 的状态代码。关于我在这里缺少什么有什么想法吗?

<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#"/> 

以下是 cfdump 的结果:

cfdump of results variable

最佳答案

您似乎使用了错误的端点。在他们的documentation中他们说:

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

在您的代码中,您使用的是 app.e2ma.net,这应该是 api.e2ma.net

此外,您请求的 URL 的路径在其文档中不包含尾部斜杠(他们拥有的是 GET/#account_id/members)。您可能还想更新它。

关于json - 使用 ColdFusion cfhttp 连接到远程 API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45963365/

相关文章:

Android从url解析json并存储

coldfusion - 如何在 Railo 中捕获 "coldfusion.runtime.MissingArgumentException"等效项?

ssl - 通过 SSL 的 CFHTTP

java - cfhttp 问题,因为它非常慢,尝试替代方案

ruby-on-rails - 是否有用于使用 JSON-API 格式的 RESTful json api 的 gem? Rails 上的 Ruby

javascript - 如何使用 AngularJS 将 json 中的 url 超链接到同一 JSON 中的文本

iphone - JSONKit 在从 iPhone 中的 Web 服务解码 JSON 对象时更改浮点值

xml - 遍历一个大的 XML 文件

json - ColdFusion 查询页面返回 JSON

php - 将 API 调用从 PHP 和 cURL 转换为 ColdFusion cfhttp