【发布时间】:2017-08-30 14:40:57
【问题描述】:
我正在尝试使用 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的结果:
【问题讨论】:
-
在成员上不带斜线试试。还要确保您使用的 account_id 有效。他们的文档与他们如何使用
#有点混淆,因为它在 URL 中有效,但是您尝试发出的请求显示时没有尾部斜杠 (GET /#account_id/members) -
试过没有斜杠,还是一样。我也认为我有正确的网址
-
我认为公共和私有 api 密钥需要作为标头而不是表单字段发送。 helpx.adobe.com/coldfusion/cfml-reference/coldfusion-tags/…
-
如果你看看他们的主页,他们有一些例子。这是 PHP 但是,他们使用
api.e2ma.net而不是app.e2ma.net。这是他们的例子:$url = "https://api.e2ma.net/".$account_id."/members/add";. -
是的,大声笑,使用正确的网址肯定会有所帮助。乍一看,我错过了。现在您应该可以使用标头进行基本身份验证了
标签: json coldfusion cfhttp