Hi.
Help with PUT HTTP request from Mikrotik router. I want to get MACs of wifi users from router to openHAB using this script.
New version of RouterOS is support any requests: https://forum.mikrotik.com/viewtopic.php?t=120860#p594370
My knowledge in RouterOS is tiny.
:global mac "88:88:88:6E:74:49"
:global OldChek
:global chek
if ([/interface wireless registration-table find mac-address=$mac] != "") do={set chek true} else={set chek false}
if (($chek != $OldChek) and ($chek = true)) do={
/log warning ($mac . " -ON")
**** this line do not work ********
/tool fetch mode=http url="http://192.168.1.11:8080/rest/items/Test_Item/state" http-method=put content-type="text/plain" http-data="payload={ \"ON\"}"
}
if (($chek != $OldChek) and ($chek = false)) do={
/log warning ($mac . " -OFF")
**** this line do not work ********
/tool fetch mode=http url="http://192.168.1.11:8080/rest/items/Test_Item/state" http-method=put content-type="text/plain" http-data="payload={ \"OFF\"}"
}
set OldChek $chek
Script is work ok.
PUT - to update item state.
POST - to send command.
To owerload content type need use directive http-header-field and set key content-type in lower case, example
http-header-field=“content-type:application/json”