使用 ColdFusion cfhttp 连接到远程 API

用户747291

我正在尝试使用 ColdFusion 连接到 emma api。使用下面的代码。尝试根据执行以下操作的 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

查尔斯

看起来您使用了错误的端点。在他们的文档中,他们说:

我们所有 API 调用的端点是https://api.e2ma.net/

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

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

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章