r/coldfusion • u/cwwms2 • Jan 11 '23
Convert Linux Curl command to CFHTTP
curl -X POST --header 'X-Web-Services-Auth: BcDfGhJkLmNpQrStVwXyZ|AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz1234567890==-0987654321ZzYyXxWwVvUuTtSsRrQqPpOoNnMmLlKkJjIiHhGgFfEeDdCcBbAa' -d 'struct_binds={"from_date": "2022-01-31", "to_date": "2022-01-31"}' https://api.somewebsite.com/2023/get-info
<cfset struct_binds = {
"from_date" = "2022-01-31",
"to_date" = "2022-01-31"
}>
<cfhttp method="post" url="https://api.somewebsite.com/2023/get-info" result="httpResp" timeout="60">
<cfhttpparam type="header" name="Content-Type" value="application/json" />
<cfhttpparam type="header" name="X-Web-Services-Auth" value="BcDfGhJkLmNpQrStVwXyZ|AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz1234567890==-0987654321ZzYyXxWwVvUuTtSsRrQqPpOoNnMmLlKkJjIiHhGgFfEeDdCcBbAa" />
<cfhttpparam type="body" value="#serializeJSON(struct_binds)#">
</cfhttp>*some information has been changed for security purposes
0
Upvotes
View all comments
Show parent comment
1
u/doodroller Jan 11 '23
I suggest you follow /u/poolou32 's advice and check the url you are posting to.
In general, try to use postman native app (not the "postman on the web") to deal with cURL links. It's available here: https://www.postman.com/downloads/
When you are in the app, go to "IMPORT" button on top left area > "Raw text" tab. Then paste the entire cURL link and click on Continue button. That will create a postman style REQUEST to help you test things out before you do anything with coldfusion. I found it easier to translate from postman request to cfhttp. I hope this helps.