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?
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