I finally got it sorted !! .. it does not work with simple API-Key approach, but you have to generate an access_token first
You just have to update:
- YOUR_API_SECRET
- YOUR_API_KEY
- your location data in the PAYLOAD node
[
{
"id": "c4bcd3228c3124f8",
"type": "inject",
"z": "f239c7a83fa7019c",
"name": "Get Fuel Data",
"props": [],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"x": 170,
"y": 1080,
"wires": [
[
"7855745c57883e66"
]
]
},
{
"id": "7855745c57883e66",
"type": "http request",
"z": "f239c7a83fa7019c",
"name": "OA",
"method": "GET",
"ret": "obj",
"paytoqs": "ignore",
"url": "https://api.onegov.nsw.gov.au/oauth/client_credential/accesstoken?grant_type=client_credentials",
"tls": "",
"persist": false,
"proxy": "",
"insecureHTTPParser": false,
"authType": "",
"senderr": false,
"headers": [
{
"keyType": "other",
"keyValue": "Authorization",
"valueType": "other",
"valueValue": "Basic YOUR_API_SECRET"
},
{
"keyType": "other",
"keyValue": "accept",
"valueType": "other",
"valueValue": "application/json"
}
],
"x": 340,
"y": 1080,
"wires": [
[
"b8c05c4a8f04f783"
]
]
},
{
"id": "b8c05c4a8f04f783",
"type": "change",
"z": "f239c7a83fa7019c",
"name": "",
"rules": [
{
"t": "set",
"p": "Fuelheck",
"pt": "flow",
"to": "payload",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 540,
"y": 1080,
"wires": [
[
"77b94dcd90ba33db"
]
]
},
{
"id": "77b94dcd90ba33db",
"type": "change",
"z": "f239c7a83fa7019c",
"name": "Payload",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "{\"fueltype\":\"P95\",\"brand\":[\"BP\"],\"namedlocation\":\"2065\",\"latitude\":\"-33.4362551\",\"longitude\":\"151.2966549\",\"radius\":\"\",\"sortby\":\"price\",\"sortascending\":\"true\"}",
"tot": "json"
},
{
"t": "set",
"p": "token",
"pt": "msg",
"to": "Fuelheck.access_token",
"tot": "flow"
},
{
"t": "set",
"p": "apikey",
"pt": "msg",
"to": "YOUR_API_KEY",
"tot": "str"
},
{
"t": "set",
"p": "time",
"pt": "msg",
"to": "iso",
"tot": "date"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 140,
"y": 1160,
"wires": [
[
"97a5360f73ba2b01"
]
]
},
{
"id": "97a5360f73ba2b01",
"type": "template",
"z": "f239c7a83fa7019c",
"name": "",
"field": "access_token",
"fieldType": "msg",
"format": "handlebars",
"syntax": "mustache",
"template": "Bearer {{token}}",
"output": "str",
"x": 290,
"y": 1160,
"wires": [
[
"44ec467e2ccaa6ea",
"532ccc37e54b3347"
]
]
},
{
"id": "44ec467e2ccaa6ea",
"type": "http request",
"z": "f239c7a83fa7019c",
"name": "Fetch from FuelCheck",
"method": "POST",
"ret": "obj",
"paytoqs": "body",
"url": "https://api.onegov.nsw.gov.au/FuelPriceCheck/v2/fuel/prices/nearby",
"tls": "",
"persist": false,
"proxy": "",
"insecureHTTPParser": false,
"authType": "",
"senderr": false,
"headers": [
{
"keyType": "other",
"keyValue": "Authorization",
"valueType": "msg",
"valueValue": "access_token"
},
{
"keyType": "other",
"keyValue": "accept",
"valueType": "other",
"valueValue": "application/json"
},
{
"keyType": "other",
"keyValue": "Content-Type",
"valueType": "other",
"valueValue": "application/json"
},
{
"keyType": "other",
"keyValue": "apikey",
"valueType": "msg",
"valueValue": "apikey"
},
{
"keyType": "other",
"keyValue": "transactionid",
"valueType": "other",
"valueValue": "Fuelid"
},
{
"keyType": "other",
"keyValue": "requesttimestamp",
"valueType": "msg",
"valueValue": "time"
}
],
"x": 530,
"y": 1160,
"wires": [
[
"82bb9e6b646d0946"
]
]
},
{
"id": "532ccc37e54b3347",
"type": "debug",
"z": "f239c7a83fa7019c",
"name": "Fuel API Output",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 470,
"y": 1200,
"wires": []
},
{
"id": "82bb9e6b646d0946",
"type": "change",
"z": "f239c7a83fa7019c",
"name": "",
"rules": [
{
"t": "set",
"p": "Fuelprice",
"pt": "flow",
"to": "payload",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 760,
"y": 1160,
"wires": [
[
"b9baa92c9834432d"
]
]
},
{
"id": "b9baa92c9834432d",
"type": "debug",
"z": "f239c7a83fa7019c",
"name": "Fuel API Output",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 790,
"y": 1220,
"wires": []
}
]