Community discussions

MikroTik App
 
sokrutin
just joined
Topic Author
Posts: 1
Joined: Sat Feb 03, 2024 3:54 pm

alcatel ik41 USB modem api

Sat Feb 03, 2024 6:19 pm

Hi. I need to poll alcatel ik41 USB modems. I preliminarily do it on Mikrotik:
/ip firewall nat add action=dst-nat chain=dstnat comment=for_reporting dst-port=14441 protocol=tcp src-address=*.*.*.0/24 to-addresses=192.168.1.1 to-ports=80
With curl, I can make a request and get a response by specifying in the header - referer: either the address of the modem 192.168.1.1 or the host of the ik41.home modem:
$header = "Referer: **ELIDED**"
$data = "{'jsonrpc':'2.0','method':'GetSystemInfo','params': '','id':'13,1'}"
$Url = "http://*.*.*.*:14441/jrd/webapi"
./curl -s $Url -H $header -d $data
{ "jsonrpc": "2.0", "result": { ....................}, "id": "13,1" }

But when I try to execute the request on Mikrotik - error - status: failed. Command:
:do {
:if [/system resource usb find vendor=Alcatel] do={
:local bridgegw [/ip route get [find gateway="bridge"] pref-src];
:local header "Referer: **ELIDED**,content-type: application/json";
:local data ("{'jsonrpc':'2.0','method':'GetSystemStatus','params':null,'id':'13.4'}");
:local url "http://$bridgegw:14441/jrd/webapi";
/tool fetch url=$url http-header-field=$header http-data=$data
}} on-error={put ""}
Tell me,please - where the error?
Last edited by tangent on Sun Feb 04, 2024 8:03 am, edited 1 time in total.
Reason: elided public domain names

Who is online

Users browsing this forum: PBondurant, webnoob and 23 guests