Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting cURL call to Coldfusion (cfhttp)

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
like image 948
erik Avatar asked Dec 15 '22 15:12

erik


2 Answers

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>
like image 145
BKK Avatar answered Jan 04 '23 10:01

BKK


This worked for me:

<cfhttp method="post" url="#myUrl#">
<cfhttpparam type="header" name="Authorization" value="Basic YWRtaW46WW91ckFQSUtleUhlcmU" />
</cfhttp>
like image 21
emanncsu Avatar answered Jan 04 '23 11:01

emanncsu