alcatel ik41 USB modem api

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?

First, thank you for the idea.

Second - in ROS 6, I could not make it work in terms that /tool fetch kept returning failed even though the IK41 was responding properly; the only “experienced guess” I could make was that the fact that IK41 uses just \n as line separator (rather than the correct \r\n as the HTTP standard requires) may prevent RouterOS 6 from distinguishing the HTTP headers of the response from one another, making the whole response incomprehensible. So I’ve made a test with ROS 7 and it works fine.

Another minor point is that fetch adds the content-type header automatically, and if you specify it manually, the POST message contains both. I have only tested this with ROS 6, so maybe ROS 7 sorts that out, but the bottom line is you don’t need to add that header manually anyway.

So the complete outcome is as follows:

:local request "{\"jsonrpc\":\"2.0\",\"method\":\"GetNetworkInfo\",\"params\":null,\"id\":\"4.1\"}" ; \
:local myData ([tool fetch \
  http-header-field="_TclRequestVerificationKey: KSDHSD--cut short for brevity--sVBNf,_TclRequestVerificationToken:null,Referer: http://192.168.1.1/default.html" \
  http-method=post \
  url="http://192.168.1.1/jrd/webapi\?api=GetNetworkInfo" \
  http-data=$request output=user as-value]->"data") ; \
put ([deserialize from=json $myData]->"result"->"SINR")
6