Community discussions

MikroTik App
 
exitcomestothis
just joined
Topic Author
Posts: 5
Joined: Sat Apr 17, 2021 6:42 pm
Location: Vancouver, WA

Fetch tool not sending all parameters

Wed Dec 15, 2021 2:35 am

I've been trying to setup a script for netwatch that will send a notification through pushover when a host is down/up. Since I'm using a KNOT (using ATT nb-iot), I've noticed that the connection for fetch will often time out before the modem has had time to establish connection, etc, so I've been trying to build a script to work around this and retry the connection.

What I've noticed though, is that if I run fetch via the CLI directly with my parameters, it will run the request and I'll get a notification. However, if I put the same code in a script, and then run the script from the CLI, returns with an HTTP 400 bad request.

Tried on ROS 6.48.3 as well as 6.49.2

Working from CLI:
/tool fetch http-method=post mode=https url="https://api.pushover.net/1/messages.json" http-data="?token=myToken&user=myUser&title=myTitle&message=myMessage&priority=1"


Not working from script:
:do {
    /tool fetch http-method=post mode=https url="https://api.pushover.net/1/messages.json" http-data="?token=myToken&user=myUser&title=myTitle&message=myMessage&priority=1"
}

I've tried setting the url and the http data in variables, as well as a couple other things over the last couple days, but this one has me stumped.

It would be awesome if fetch had a timeout to deal with the cellular delay for connections like NB-IOT on the KNOT :D
Last edited by exitcomestothis on Mon Dec 20, 2021 11:59 pm, edited 1 time in total.
 
exitcomestothis
just joined
Topic Author
Posts: 5
Joined: Sat Apr 17, 2021 6:42 pm
Location: Vancouver, WA

Re: Fetch tool not sending all parameters  [SOLVED]

Mon Dec 20, 2021 11:57 pm

So, after toying around with this some more over the last few days, I found out what I was doing wrong. It seems that passing along the "?" in the http-data string is causing the problem.

Removing the questionmark has resolved the issue, and I'm now able to use the fetch tool within my script.

Working from script
:do {
    /tool fetch http-method=post mode=https url="https://api.pushover.net/1/messages.json" http-data="token=myToken&user=myUser&title=myTitle&message=myMessage&priority=1"
}

Who is online

Users browsing this forum: No registered users and 25 guests