Getting data from external source with REST

Hey all,

It has been some time since I have used Ignition and things have changed.

I am now trying log data from an web platform collecting data from wireless sensors in the field.

The 3rd party system generates the JSON text to get the data for a particular sensor but I am unsure how to integrate the data in Ignition.

Ideally I would like to have it in a tag.

curl --location --request POST 'https://us-central1-neuron2.cloudfunctions.net/sensorInfo' \
--header 'Content-Type: application/json' \
--data-raw '{ 
	"apiKey": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
	"sn": "3000568345"
}'

Any ideas?

Thanks
Ivan

You’ll probably want to use the httpPost() system function.
system.net.httpPost - Ignition User Manual 8.1 - Ignition Documentation (inductiveautomation.com)

Not httpPost. Use httpClient.

3 Likes

Are those your real API key and such ?
You might want to hide them if that’s the case.

1 Like
client = system.net.httpClient()
data = {
	"apiKey": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
	"sn": "3000568345"
}
client.post("https://us-central1-neuron2.cloudfunctions.net/sensorInfo", data=data)

This would be an exactly equivalent request to the CURL example above, though POST is probably not the verb I would expect to use to retrieve data.

Paul,

Many thanks!

This worked straight away.

Cheers
Ivan