Node Red HTTP Post

Has anyone tried to create a flow in Node Red with their Spark core? The http post connects to my device but returns a value of -1. I am using the following url.

https://api.spark.io/v1/devices/50ff70065067545652160487/analogread?access_token=######&params=A0

Node Red Flow and result

Is analogread a `Spark.variable()?

I think he must have Tinker loaded on the core. That command should work OK with Tinker.

Yes, I’m using a HTTP Request GET command and a variable on the spark core to detect motion.

https://api.spark.io/v1/devices/53ff6d065067544813181187/motion?access_token=#######

It works well for me.

Hi @tinkerMike,

I think the problem you’re running into is ‘analogread’ is a spark.function, so it’s expecting a http POST request, and I’m guessing that http request is a GET.

Thanks!
David

1 Like

@lightx - Have you tried a function where you pass the pin number? I can get the variable returned and that might be good enough for now but I was hoping to have a function to call.

There are both POST and GET Methods on the HTTP Request Node

HTTP Request Node

For the GET method, I successfully accessed a variable:

https://api.spark.io/v1/devices/50ff70065067545652160487/temperature?access_token=######

For the POST method, I unsuccessfully tried to access the Tinker app function:

https://api.spark.io/v1/devices/50ff70065067545652160487/analogread?access_token=######&params=A0

@tinkerMike - the only way I found to work was to use exec since I couldn’t figure out how to pass arguments in the http request. Ive used something along the lines of

curl "https://api.spark.io/v1/devices/53ff6d065067544813181187/led?access_token=######" -d "args=on"

I was able to do it without using the exec block, see this flow:

1 Like