I am sending some data from routeros to a dashboarding application called Thingsboard via http/curl.
I recently upgraded to routeros v6.44 and I read in the forums that I need to change the fetch command from "http-content-type" to http-header-field="Content-Type: xxx".
I have done this and it works for one of my scripts. However, it does not work for the script that sends the GPS position information. In this case, the script appears to run OK as the GPS data appears in the CLI in the correct format, but does not update the Thingsboard application. Nothing has changed in Thingsboard, the only change is the routeros upgrade and the above syntax. Here is the script:
Code: Select all
{
:global lat
:global lon
/system gps monitor once do={
:set $lat $("latitude")
:set $lon $("longitude")
};
:tool fetch mode=http url="http://10.0.1.186/api/v1/<<my key>>/telemetry" port=9090 http-method=post \
http-data=("{\"latitude\":\"" . $lat . "\",\"longitude\":\"" . $lon . "\"}") http-header-field="Content-Type:application/json"
:put ("{\"latitude\":\"" . $lat . "\",\"longitude\":\"" . $lon . "\"}")
};
Code: Select all
[admin@gsm_bl02a] > system script run tracker
date-and-time: apr/17/2019 08:32:23
latitude: N 55 58' 9.78''
longitude: W 3 9' 53.10''
altitude: 22.500000m
speed: 2.759480 km/h
destination-bearing: none
true-bearing: 19.850000 deg. True
magnetic-bearing: none
valid: yes
satellites: 6
fix-quality: 1
horizontal-dilution: 1.7
status: finished
downloaded: 0KiBC-z pause]
duration: 1s
{"latitude":"N 55 58' 9.78''","longitude":"W 3 9' 53.10''"}
Any help appreciated.
Alan