Translate cfexecute to cfhttp


#1

Hi,

I wonder if anyone has done anything like the following:

<cfset token = "ksk9399dkkskk2k32k3">
<cfexecute name="curl -s -X POST
http://123.456.77.88:3000/channels/mychannel/mycode
-H 'authorization: Bearer #token#' 
-H 'content-type: application/json'
-d '{""peers"":
[""peer0.xyz.com"",""peer1.xyz.com""],""chaincodeType"":
""node"",
""fcn"":""addStuff"",
""args"":[""#FORM.myid#"",""#FORM.field1#"",""#FORM.field2#"",""#FORM.field3#"",""#FORM.field4#"",
""#dateformat(FORM.mydatefield,'mm/dd/yyyy')#""]}' " 
timeout="90">
</cfexecute>

The -H switch can be easily taken care of, however, the -d switch has massive json data, any way to handle it with cfhttp?

fyi, i’m using lucee docker image 52

Thanks.


#2

You can use cfhttpparam with type=“body” value="#yourJSON#"


#3

Thanks, someone also suggested this technique as well, awesome, resolved, much appreciated.


#4

for cfexecute seems like it always works better if you write a script like a bash / etc and call that with parameters.