Converting cURL call to Coldfusion (cfhttp)

北慕城南 提交于 2020-01-04 04:40:12

问题


This may be pretty simple, not entirely sure. Is there a way to take this cURL call below (it's from Big Commerce's API) and rewrite the same function using cfhttp? I know cfhttp acts (or can act like) a form/method="post" type deal, but I'm not sure what params (or what their names should be) to use within a cfhttp tag. Any help would be appreciated...my goal is to be able to use Coldfusion to call a list of products, at which point I can arrange/export to a list/excel/whatever, but setting up the actual call using cfhttp and converting this cURL call is what I'm stuck at.

curl --request GET \
 --user-agent "Your Client Name/1.0" \
 --header "Authorization: Basic YWRtaW46WW91ckFQSUtleUhlcmU=" \
 https://www.example.com/api/v2/products

回答1:


Should be something along the lines of:

<cfhttp
    method="get"
    url="https://www.example.com/api/v2/products"
    userAgent="Your Client Name/1.0">
    <cfhttpparam type="header" value="Authorization: Basic YWRtaW46WW91ckFQSUtleUhlcmU=">
</cfhttp>



回答2:


This worked for me:

<cfhttp method="post" url="#myUrl#">
<cfhttpparam type="header" name="Authorization" value="Basic YWRtaW46WW91ckFQSUtleUhlcmU" />
</cfhttp>


来源:https://stackoverflow.com/questions/14227925/converting-curl-call-to-coldfusion-cfhttp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!