Send data with JSON

Contributor ,
Jul 17, 2019 Jul 17, 2019

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

Views

493

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct Answer

Participant , Jul 17, 2019 Jul 17, 2019
You need something like<cfhttpmethod="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...

Likes

Translate

Translate
Participant ,
Jul 17, 2019 Jul 17, 2019

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 18, 2019 Jul 18, 2019

Copy link to clipboard

Copied

LATEST

The value of an attribute is enclosed in double quotes. When quotes are used in a string they must be doubled.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines