Http request with payload

#1

Hi. Is it possible to use msg payload in http url. for example
192.168.*********/ref=79&value=(msg.payload) I want this result value=1

/Niclas

0 Likes

#2

Hi - yes you can. This recipe shows you how: https://cookbook.nodered.org/http/set-query-string

0 Likes

#3

Thank you! Have tried but I don't succeed. What am I doing wrong.

0 Likes

#4

What is the value of msg.payload when you pass it to this node?

0 Likes

#5

It is 100 or 0. Have also removed 1 after = in my example

0 Likes

#6

So the url you have will contain &value=100&format=json

The response you are getting back from the request tells you the problem: "Error, data is not in json format". Sure enough, you have format set to 'json' but 'value' is not set to a JSON value, just a raw number.

You'll have to refer to the documentation of whatever API you're using to get the format right.

0 Likes

#7

This is what it look like in a web browser. This sets the device to on

0 Likes

#8

And does it have format=json in the url when you access it in the browser? I don't see it in the screenshot.

0 Likes

#9

Solved it. Was a big miss from me. It was not post, Change it to get and it worked.
Thank you for your help

Best regards Niclas

0 Likes