Page 1 of 1

[SOLVED] fetch url problem / sms api

Posted: Mon Oct 21, 2013 3:11 pm
by resnik
Hi, I'm trying to write a working script to send me SMS via API, the manual for API service can be found here

The script I tried and following error (personal data omitted):
/tool> fetch url="http://rest.nexmo.com/sms/xmlapi_key=KEY&api_secret=PASS&from=Gatekeeper&to=NUMBER&text=test_msg"     
  status: failed

failure: closing connection: <404 Not Found> 173.193.199.22:80 (4)
or
/tool> fetch address="rest.nexmo.com" mode=http src-path="/sms/xmlapi_key=KEY&api_secret=PASS&from=Gatekeeper&to=NUMBER&text=test_msg"     
  status: failed

failure: closing connection: <302 Moved Temporarily> 174.37.245.36:80 (4)
any idea how to get this working?

Re: fetch url problem / sms api

Posted: Mon Oct 21, 2013 7:48 pm
by boen_robot
Try to clear your DNS cache with
/ip dns cache flush
before you make the request.

It appears nexmo recently changed their server, but are still keeping the old one to redirect to the new one, before they eventually take it down. "/tool fetch" doesn't cope well with redirects. Clearing the cache should point it to their new server.

Re: fetch url problem / sms api

Posted: Mon Oct 21, 2013 10:07 pm
by resnik
Did not help much, for now I resorted to PHP nexmo library that's running on my server, and fetch is working normally there, maybe at some point add lighttpd server on Metarouter, and put scripts there.

Re: fetch url problem / sms api

Posted: Tue Jun 10, 2014 3:22 pm
by resnik
found the solution today. Changed all "?" to "\?"

ros code

fetch keep-result=no url="http://rest.nexmo.com/sms/xml\?api_key= ... ER=MESSAGE"

Re: fetch url problem / sms api

Posted: Wed Feb 17, 2021 7:59 am
by otgooneo
found the solution today. Changed all "?" to "\?"

ros code

fetch keep-result=no url="http://rest.nexmo.com/sms/xml\?api_key= ... ER=MESSAGE"
It helps. Thank you.

Re: [SOLVED] fetch url problem / sms api

Posted: Mon May 24, 2021 4:25 pm
by hendranug
anyone can help with 5.20 version?
it still say

status: failed

failure: 301 Moved Permanently
-------------------------------------------------------------------------
trying another
[hendra@MikroTik] > /tool fetch mode=http address="tunnel.hostddns.us" src-path="/ddns" dst-path="/fddea32284b91e43acfef819d4997c83"
status: failed

failure: 302 Found

still same.

Re: fetch url problem / sms api

Posted: Thu Aug 29, 2024 12:07 pm
by uzairshahbaz
found the solution today. Changed all "?" to "\?"

ros code

fetch keep-result=no url="http://rest.nexmo.com/sms/xml\?api_key= ... ER=MESSAGE"

Thanks, it helped.