Community discussions

MikroTik App
 
User avatar
resnik
newbie
Topic Author
Posts: 27
Joined: Wed Mar 31, 2010 5:25 pm
Location: Europe

[SOLVED] fetch url problem / sms api

Mon Oct 21, 2013 3:11 pm

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?
Last edited by resnik on Tue Jun 10, 2014 3:24 pm, edited 1 time in total.
 
User avatar
boen_robot
Forum Guru
Forum Guru
Posts: 2400
Joined: Thu Aug 31, 2006 4:43 pm
Location: europe://Bulgaria/Plovdiv

Re: fetch url problem / sms api

Mon Oct 21, 2013 7:48 pm

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.
 
User avatar
resnik
newbie
Topic Author
Posts: 27
Joined: Wed Mar 31, 2010 5:25 pm
Location: Europe

Re: fetch url problem / sms api

Mon Oct 21, 2013 10:07 pm

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.
 
User avatar
resnik
newbie
Topic Author
Posts: 27
Joined: Wed Mar 31, 2010 5:25 pm
Location: Europe

Re: fetch url problem / sms api

Tue Jun 10, 2014 3:22 pm

found the solution today. Changed all "?" to "\?"

ros code

fetch keep-result=no url="http://rest.nexmo.com/sms/xml\?api_key= ... ER=MESSAGE"
 
User avatar
otgooneo
Trainer
Trainer
Posts: 581
Joined: Tue Dec 01, 2009 3:24 am
Location: Mongolia
Contact:

Re: fetch url problem / sms api

Wed Feb 17, 2021 7:59 am

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.
 
hendranug
just joined
Posts: 1
Joined: Mon May 24, 2021 12:07 pm

Re: [SOLVED] fetch url problem / sms api

Mon May 24, 2021 4:25 pm

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.
Last edited by hendranug on Mon May 24, 2021 4:44 pm, edited 1 time in total.

Who is online

Users browsing this forum: doridian, druidgtx, rore22 and 22 guests