I’m using GideonLeGrange Java API :
https://github.com/GideonLeGrange/mikrotik-java
I’m trying to unset the address field for specific user, i’ve tried to use the unset command like this :
con.execute("/ip/hotspot/user/unset .id="+userId+" value-name=address");
Or
con.execute("/ip/hotspot/user/unset .id="+userId+" address");
it gives me “no such command” error.
tried to set it to empty value like this :
con.execute("/ip/hotspot/user/set .id="+userId+" address");
Or
con.execute("/ip/hotspot/user/set .id="+userId+" address=");
But it gives me empty error (a blank error message).
I’m using version 5.25 of RouterOS.
So how can i achieve that?
Looking at it from terminal, indeed, there is no “unset” command at that menu.
So you can’t really do that. You can just use “set” to set the value to an empty string, which RouterOS would treat the same as there being nothing (if it didn’t, there would be an “unset” command). Also, although “.id” works, it’s technically more correct (or at least consistent with terminal) to use “numbers”, so:
con.execute("/ip/hotspot/user/set numbers="+userId+" address=''");
Setting it to empty string gave me an empty string error, so i have tried to set the address field to 0.0.0.0 and it worked! also it worked for mac-address like that 00:00:00:00:00:00 and i think it should be the default value for addresses to unset.
con.execute("/ip/hotspot/user/set .id="+userId+" address='0.0.0.0'");
con.execute("/ip/hotspot/user/set .id="+userId+" mac-address='00:00:00:00:00:00'");
Thank you so much for your help.