Hello,
I would like to show the the current petrol prices to my dashboard.
For the data reference I use this link.
He explains how can I configure a http request.
For Example:
- Url: https://carburanti.mise.gov.it/ospzApi/search/area
- Header: vuoto
- Payload:
- region: (numero),
- province: (sigla della provincia oppure null; il link di esempio fornisce l'elenco delle province della regione 9 (Lazio)),
- town: (nome del coumne oppure null; il link di esempio fornisce la lista dei comuni della provincia di Roma),
- priceOrder: "asc" o "desc",
- fuelType: "FuelType-RefuelingMode" (FuelType e RefuelingMode sono numeri (v. sotto))
Example of the header complete:
{
"region" : 9,
"province" : "RM",
"town" : "Monterotondo",
"priceOrder" : "desc",
"fuelType": "1-1",
"refuelingMode" : 1
}
For my Node-RED project I found this as a possible solution:
https://cookbook.nodered.org/http/set-request-header
I create this node, but unfortunately it doesn't work:
[
{
"id": "cf770b6810ef06f2",
"type": "inject",
"z": "67e5e39e7b6a8e54",
"name": "",
"repeat": "",
"crontab": "",
"once": false,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 220,
"y": 3500,
"wires": [
[
"28957e037055f9ad"
]
]
},
{
"id": "28957e037055f9ad",
"type": "function",
"z": "67e5e39e7b6a8e54",
"name": "set payload and headers",
"func": "msg.headers = {};\nmsg.headers = {\n};\n\n\nmsg.payload = {};\nmsg.payload = {\n 'region' : 9,\n 'province': 'RM',\n 'town' : 'Monterotondo',\n 'priceOrder':'desc', \n 'fuelType': '1-1',\n 'refuelingMode': 1\n};\n\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 410,
"y": 3500,
"wires": [
[
"032934fb12b24bb2"
]
]
},
{
"id": "032934fb12b24bb2",
"type": "http request",
"z": "67e5e39e7b6a8e54",
"name": "post to HttpBin",
"method": "POST",
"ret": "obj",
"paytoqs": "ignore",
"url": "https://carburanti.mise.gov.it/ospzApi/search/area",
"tls": "",
"persist": false,
"proxy": "",
"insecureHTTPParser": false,
"authType": "",
"senderr": false,
"headers": [],
"credentials": {},
"x": 620,
"y": 3500,
"wires": [
[
"62e926b2531c4d02"
]
]
},
{
"id": "62e926b2531c4d02",
"type": "debug",
"z": "67e5e39e7b6a8e54",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 790,
"y": 3500,
"wires": []
}
]
I hope somebody can help me.
Thanks in advance.
Bye.