Community discussions

MikroTik App
 
biz2240
just joined
Topic Author
Posts: 5
Joined: Mon Feb 22, 2016 5:12 am

API Code not functional after upgrade to 6.42.5

Thu Jun 28, 2018 8:34 pm

This code was functional with an old version, but is not functional with the version 6.42.5

I want to change my gateway from 192.168.1.1 to 192.168.5.1. I was using this command:

/ip/route/set
=gateway=192.168.5.1
?dst-address=0.0.0.0/0

I receive the result: !done

But nothing change.

Is there a new API version?
 
nescafe2002
Forum Veteran
Forum Veteran
Posts: 897
Joined: Tue Aug 11, 2015 12:46 pm
Location: Netherlands

Re: API Code not functional after upgrade to 6.42.5

Thu Jun 28, 2018 9:44 pm

You're combining a query with a set operation which has never been possible in API (and if it was, I'm curious which version..).

This is documented here: https://wiki.mikrotik.com/wiki/Manual:API#Queries
print command accepts query words that limit set of returned sentences.

The API conversation should be:
/ip/route/print
?dst-address=0.0.0.0/0
!re=.id=*1=dst-address=0.0.0.0/0=gateway=192.168.5.2=gateway-status=192.168.5.2 unreachable=distance=1=scope=30=target-scope=10=active=false=static=true=disabled=false
!done

Then you should update the item based on .id:

/ip/route/set
=.id=*1
=gateway=192.168.5.1
!done

And it will update successfully:

/ip/route/print
?dst-address=0.0.0.0/0
!re=.id=*1=dst-address=0.0.0.0/0=gateway=192.168.5.1=gateway-status=192.168.5.1 unreachable=distance=1=scope=30=target-scope=10=active=false=static=true=disabled=false
!done

Who is online

Users browsing this forum: No registered users and 67 guests