URL variables http get request

#1

Hi there

I am a Visual Studio Web Developer and have recently started using Node Red and all is new to me.
I want to pass a variable result using a URL such as https://xxxxx.fred.sensetecnic.com/api/var/?weight=40 from another device and then get the URL via http get request and display it on a chart. If someone can be of assistance I would really appreciate it. I understand it should be very simple and short.

Kind regards

#2

What have you tried, where are you stuck?

If you post the flow you have we can suggest where you night be going wrong.

These pages might also be of help
https://cookbook.nodered.org

flows.nodered.org which contains flows you can import into node-red

#3

[

[

{

"id": "e04a7b54.d403d8",

"type": "inject",

"z": "5230c72.fadcf38",

"name": "",

"topic": "",

"payload": "",

"payloadType": "date",

"repeat": "",

"crontab": "",

"once": false,

"onceDelay": 0.1,

"x": 220,

"y": 240,

"wires": [

[

"f5d7c950.a5dfe8"

]

]

},

{

"id": "f5d7c950.a5dfe8",

"type": "http request",

"z": "5230c72.fadcf38",

"name": "",

"method": "GET",

"ret": "obj",

"url": "https://riaan.fred.sensetecnic.com/api/var",

"tls": "",

"x": 400,

"y": 240,

"wires": [

[

"18aad5a3.efd42a",

"9311fd84.3f5d5"

]

]

},

{

"id": "18aad5a3.efd42a",

"type": "debug",

"z": "5230c72.fadcf38",

"name": "",

"active": true,

"tosidebar": true,

"console": false,

"tostatus": false,

"complete": "false",

"x": 620,

"y": 240,

"wires": []

},

{

"id": "9311fd84.3f5d5",

"type": "function",

"z": "5230c72.fadcf38",

"name": "return ",

"func": "return {\n payload: msg.payload.length\n};",

"outputs": 1,

"noerr": 0,

"x": 640,

"y": 340,

"wires": [

[

"6e22171f.b754f8",

"8d4bd9ed.9e3768"

]

]

},

{

"id": "6e22171f.b754f8",

"type": "debug",

"z": "5230c72.fadcf38",

"name": "",

"active": true,

"tosidebar": true,

"console": false,

"tostatus": false,

"complete": "false",

"x": 860,

"y": 360,

"wires": []

},

{

"id": "8d4bd9ed.9e3768",

"type": "ui_gauge",

"z": "5230c72.fadcf38",

"name": "",

"group": "2472295d.217b26",

"order": 0,

"width": 0,

"height": 0,

"gtype": "gage",

"title": "gauge",

"label": "units",

"format": "{{value}}",

"min": 0,

"max": 10,

"colors": [

"#00b500",

"#e6e600",

"#ca3838"

],

"seg1": "",

"seg2": "",

"x": 860,

"y": 440,

"wires": []

},

{

"id": "2472295d.217b26",

"type": "ui_group",

"z": "",

"name": "weight",

"tab": "",

"disp": true,

"width": "6",

"collapse": false

}

]

Like I said I'm a first timer, trying to figure out how everything comes together. I want to open the url for example

https://riaan.fred.sensetecnic.com/api/var/?weight=25 on another device and then the gauge should display 25.

Thanks in advance

#4

Step 1: Please read How to share code or flow json and then edit your post above

#5

[

{

"id": "5230c72.fadcf38",

"type": "tab",

"label": "Sheet 1"

},

{

"id": "e04a7b54.d403d8",

"type": "inject",

"z":
"5230c72.fadcf38",

"name": "",

"topic": "",

"payload": "",

"payloadType": "date",

"repeat": "",

"crontab": "",

"once": false,

"onceDelay": 0.1,

"x":
220,

"y":
240,

"wires": [

[

"f5d7c950.a5dfe8"

]

]

},

{

"id": "f5d7c950.a5dfe8",

"type": "http request",

"z":
"5230c72.fadcf38",

"name": "",

"method": "GET",

"ret": "obj",

"url": "[https://riaan.fred.sensetecnic.com/api/var](https://riaan.fred.sensetecnic.com/api/var)",

"tls": "",

"x":
400,

"y":
240,

"wires": [

[

"18aad5a3.efd42a",

"9311fd84.3f5d5"

]

]

},

{

"id":
"18aad5a3.efd42a",

"type": "debug",

"z":
"5230c72.fadcf38",

"name": "",

"active": true,

"tosidebar": true,

"console": false,

"tostatus": false,

"complete": "false",

"x":
620,

"y":
240,

"wires": []

},

{

"id": "9311fd84.3f5d5",

"type": "function",

"z":
"5230c72.fadcf38",

"name": "return ",

"func": "return {\n   
payload: msg.payload.length\n};",

"outputs": 1,

"noerr": 0,

"x":
640,

"y":
340,

"wires": [

[

"6e22171f.b754f8",

"8d4bd9ed.9e3768"

]

]

},

{

"id": "6e22171f.b754f8",

"type": "debug",

"z":
"5230c72.fadcf38",

"name": "",

"active": true,

"tosidebar": true,

"console": false,

"tostatus": false,

"complete": "false",

"x":
860,

"y":
360,

"wires": []

},

{

"id": "8d4bd9ed.9e3768",

"type": "ui_gauge",

"z":
"5230c72.fadcf38",

"name": "",

"group": "2472295d.217b26",

"order": 0,

"width": 0,

"height": 0,

"gtype": "gage",

"title": "gauge",

"label": "units",

"format": "{{value}}",

"min": 0,

"max": 10,

"colors": [

"#00b500",

"#e6e600",

"#ca3838"

],

"seg1": "",

"seg2": "",

"x":
860,

"y":
440,

"wires": []

},

{

"id": "de6c3996.0a78a8",

"type": "http in",

"z":
"5230c72.fadcf38",

"name": "/var",

"url": "/var",

"method": "get",

"upload": false,

"swaggerDoc": "",

"x":
200,

"y":
140,

"wires": [

[

"f5d7c950.a5dfe8",

"7cfd1c48.f8a104"

]

]

},

{

"id": "7cfd1c48.f8a104",

"type": "debug",

"z":
"5230c72.fadcf38",

"name": "",

"active": false,

"tosidebar": true,

"console": false,

"tostatus": false,

"complete": "payload",

"x":
450,

"y":
120,

"wires": []

},

{

"id": "2472295d.217b26",

"type": "ui_group",

"z":
"",

"name": "weight",

"tab": "",

"disp": true,

"width": "6",

"collapse": false

}

]

#6

Please let me know if the new code posted above is still not in correct format. Thanks. Regards

#7

I'm not infront of my PC at the moment. But if you can copy from and paste into Node-RED it's in the correct format. If not please EDIT your post rather than posting again.