Copy link to clipboard
Copied
I am trying to learn how to post data to an external site using JSON. The example the vendor gave me looks like this:
curl -XPOST --data '{"audioLevel": 50, "url": "http://some-stream.de/"}'
http://TheirURL.com:7000/device/00:08:e1:06:c5:39/send
From doing some research I think I need to make an array, the SerializeJSON the array then use CFHTTP to send it. I can't find anything that explains the curl -XPOST --data
I am struggling to try to wrap my head around this. Would appreciate any pointers.
Thanks,
Gary
You need something like
<
cfhttp
method=
"post"
url=
"http://TheirURL.com:7000/device/00:08:e1:06:c5:39/send"
throwonerror=
"Yes"
>
<
cfhttpparam
type=
"body"
value=
"{""audioLevel"": 50, ""url"": ""http://some-stream.de/""}"
>
</
cfhttp
>
You can generate the body by building a structure in ColdFusion and use serializeJSON to put it in the value attribute. Take care for the casing of the word audioLevel.
curl is a command line tool that allows to send http requests. It can be used for testing. You can put eve
...Copy link to clipboard
Copied
You need something like
<
cfhttp
method=
"post"
url=
"http://TheirURL.com:7000/device/00:08:e1:06:c5:39/send"
throwonerror=
"Yes"
>
<
cfhttpparam
type=
"body"
value=
"{""audioLevel"": 50, ""url"": ""http://some-stream.de/""}"
>
</
cfhttp
>
You can generate the body by building a structure in ColdFusion and use serializeJSON to put it in the value attribute. Take care for the casing of the word audioLevel.
curl is a command line tool that allows to send http requests. It can be used for testing. You can put everything in a cfexecute tag, if you wish. curl is freely available for download on: curl
Copy link to clipboard
Copied
The value of an attribute is enclosed in double quotes. When quotes are used in a string they must be doubled.