Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Send data with JSON

Contributor ,
Jul 17, 2019 Jul 17, 2019

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

880
Translate
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

<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

...
Translate
Participant ,
Jul 17, 2019 Jul 17, 2019

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

Translate
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
LATEST

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

Translate
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
Resources