Community discussions

MikroTik App
 
oguruma
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 83
Joined: Sat Jun 04, 2022 8:55 pm

REST API Script: Authorization header?

Mon Apr 24, 2023 5:54 am

I'm working on a script that will send an LTAPs coordinates to my homeassistant box.

I have the script below, but doesn't look like it's even reaching the home assistant install. The LTAP is on the LAN with the Homeassistant.

I think the issue might be that I'm improperly declaring the ' Authoization: Bearer' but the documentation doesn't specify how to do it.

The API call works when I try it from Postman. I put hard-coded values in the lat/long for testing.
{
:global lat
:global lon
/system gps monitor once do={
:set $lat $("latitude")
:set $lon $("longitude")
}
tool fetch mode=http url="http://192.168.55.0/api/states/vehicle.tested_gps" port=8123 http-method=post http-data=("{
    "state": "vehicle_on",
    "attributes": {
        "latitude":"34.1234",
        "longitude":"-154.1234"
    }
}") http-header-field="Content-Type: application/json,Authorization: Bearer mybearertoken"
}

Who is online

Users browsing this forum: alexantao, hmdslm, tunguskalabs and 18 guests