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: 2411
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.
PEAR2_Net_RouterOS(1.0.0b6) - My API client in PHP
(Rate my posts? If you want... no pressure...)
 
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: 578
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.
----------------------------
Want to learn more and more...

Who is online

Users browsing this forum: No registered users and 35 guests