Community discussions

MikroTik App
 
Thamer
just joined
Topic Author
Posts: 20
Joined: Sun Oct 05, 2008 8:46 am

why? API disable hotspot user fail

Sun Feb 21, 2010 1:48 am

Hi everyone
I try to create my own API in vb.net language
I have used this code to disable users in hotspot, but didn't work :(
 mikrotik.Send("/ip/hotspot/user/set/=.name=user1=disabled=yes", True)
any advice ?
thanks
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8712
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: why? API disable hotspot user fail

Sun Feb 21, 2010 6:28 pm

 
Thamer
just joined
Topic Author
Posts: 20
Joined: Sun Oct 05, 2008 8:46 am

Re: why? API disable hotspot user fail

Sun Feb 21, 2010 7:17 pm

thanks for replay ,
I have tested this code, but also failed :?
        mikrotik.Send("/ip/hotspot/user/print", True)
        mikrotik.Send("=.proplist=.id", True)
        mikrotik.Send("?comment=teste", True)
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8712
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: why? API disable hotspot user fail

Sun Feb 21, 2010 7:39 pm

not '=.proplist', but '.proplist'
 
Thamer
just joined
Topic Author
Posts: 20
Joined: Sun Oct 05, 2008 8:46 am

Re: why? API disable hotspot user fail

Mon Feb 22, 2010 12:19 am

not '=.proplist', but '.proplist'
thank you so much for your help

i face this message
   !trap=message=no such command prefix!done
what can i do to disable hotspot account using API ?
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8712
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: why? API disable hotspot user fail

Mon Feb 22, 2010 12:36 am

by the way, last line should be not 'mikrotik.Send("?comment=teste", True)' but 'mikrotik.Send("?comment=teste", False)'

and for you it should be
mikrotik.Send("?name=user1", False)
message=no such command prefix
and what if just
mikrotik.Send("/ip/hotspot/user/print", False)
?..
 
Thamer
just joined
Topic Author
Posts: 20
Joined: Sun Oct 05, 2008 8:46 am

Re: why? API disable hotspot user fail

Mon Feb 22, 2010 3:21 am

by the way, last line should be not 'mikrotik.Send("?comment=teste", True)' but 'mikrotik.Send("?comment=teste", False)'
and for you it should be
mikrotik.Send("?name=user1", False)
I have used the search by name and comment and all of them do not work .
message=no such command prefix
and what if just
mikrotik.Send("/ip/hotspot/user/print", False)
?..
if i use just this code , it bring my customer data without disable any account .

by the way, what this code do ?
mikrotik.Send("=.id=*4EB", True)
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8712
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: why? API disable hotspot user fail

Mon Feb 22, 2010 3:25 am

first, re-read the posts at that topic. you should do what you want in two steps. "=.id=*4EB" is .id, obtained from the first step

secont, what version of ROS do you use? queries (like '?comment=something') can be used since v3.21
 
Thamer
just joined
Topic Author
Posts: 20
Joined: Sun Oct 05, 2008 8:46 am

Re: why? API disable hotspot user fail

Mon Feb 22, 2010 6:10 am

first, re-read the posts at that topic. you should do what you want in two steps. "=.id=*4EB" is .id, obtained from the first step

secont, what version of ROS do you use? queries (like '?comment=something') can be used since v3.21
ok , this is the complete code
        mikrotik.Send("/ip/hotspot/user/print", False)
        mikrotik.Send("=.proplist=.id", False)
        mikrotik.Send("?name=user1", False)
             For Each h As String In mikrotik.Read()
                 TextBox1.Text &= h
             Next
        mikrotik.Send("/ip/hotspot/user/set", False)
        mikrotik.Send("=.id=h", False)
        mikrotik.Send("=disabled=yes", False)
my ROS is 3.30 :?

thanks .
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8712
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: why? API disable hotspot user fail

Mon Feb 22, 2010 12:13 pm

not
mikrotik.Send("/ip/hotspot/user/print", False)
mikrotik.Send("=.proplist=.id", False)
mikrotik.Send("?name=user1", False)
but
mikrotik.Send("/ip/hotspot/user/print", True)
mikrotik.Send("=.proplist=.id", True)
mikrotik.Send("?name=user1", False)
- it's one command, not three commands

so, what does it return?
 
Thamer
just joined
Topic Author
Posts: 20
Joined: Sun Oct 05, 2008 8:46 am

Re: why? API disable hotspot user fail

Mon Feb 22, 2010 4:59 pm

not
mikrotik.Send("/ip/hotspot/user/print", False)
mikrotik.Send("=.proplist=.id", False)
mikrotik.Send("?name=user1", False)
but
mikrotik.Send("/ip/hotspot/user/print", True)
mikrotik.Send("=.proplist=.id", True)
mikrotik.Send("?name=user1", False)
- it's one command, not three commands

so, what does it return?
ok , what can i do to make it one command not three ?
because the above code return the same message !
can i use something like this, to make the code one command ?
mikrotik.Send("/ip/hotspot/user/print", True), ("=.proplist=.id", True),("?name=user1", False)
thanks .
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8712
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: why? API disable hotspot user fail

Mon Feb 22, 2010 11:45 pm

ok , what can i do to make it one command not three ?
mikrotik.Send("/ip/hotspot/user/print", True)
mikrotik.Send("=.proplist=.id", True)
mikrotik.Send("?name=user1", False)
the above code return the same message !
please quote exact code and exact response
 
Thamer
just joined
Topic Author
Posts: 20
Joined: Sun Oct 05, 2008 8:46 am

Re: why? API disable hotspot user fail

Tue Feb 23, 2010 1:41 am

please quote exact code and exact response
sorry for disturbing you :(

this code
   mikrotik.Send("/ip/hotspot/user/print", True)
   mikrotik.Send("=.proplist=.id", True)
   mikrotik.Send("?name=user1", False)
return ( !trap=message=no such command prefix!done )

i don't know how can i thank you for your help :roll:
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8712
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: why? API disable hotspot user fail

Tue Feb 23, 2010 2:36 am

what programming language do you use?..

try removing second or third lines - see whether result changes (and don't forget about second argument, only in last line it should be False)
 
Thamer
just joined
Topic Author
Posts: 20
Joined: Sun Oct 05, 2008 8:46 am

Re: why? API disable hotspot user fail

Wed Feb 24, 2010 3:27 am

what programming language do you use?..

try removing second or third lines - see whether result changes (and don't forget about second argument, only in last line it should be False)
finally I made it :D
this code is working well
        mikrotik.Send("/ip/hotspot/user/set")
        mikrotik.Send("=disabled=yes")
        mikrotik.Send("=.id=user1", True)
thank you so much for your help and your support :D
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: why? API disable hotspot user fail

Wed Feb 24, 2010 12:25 pm

        mikrotik.Send("/ip/hotspot/user/set")
        mikrotik.Send("=disabled=yes")
        mikrotik.Send("=.id=user1", True)
to make things clearer for other, what i quoted is one command with arguments you send to RouterOS through API. This example is in one specific implementation of API, without that wrapper:
/ip/hotspot/user/set
=disabled=yes
=.id=user1
and use .id value not name, to address entry, as that is unique number that is assigned to that entry and wont change over time.
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8712
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: why? API disable hotspot user fail

Wed Feb 24, 2010 8:45 pm

=.id=user1
omg! it's working! so, in .id, you can send not only unique id of the item, but also the name!

when was it introduced? will it be supported in the future?
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: why? API disable hotspot user fail

Wed Mar 03, 2010 10:53 am

Sometimes it works. Also, that is possible because of some legacy stuff. I would not rely that that is possible in future versions.

EDIT:

it is official - if entry have name field it can be address that way using API. Full name should be supplied.
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8712
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: why? API disable hotspot user fail

Fri Mar 05, 2010 1:02 am

super!

maybe, it should be mentioned in the Wiki? =)
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: why? API disable hotspot user fail

Fri Mar 05, 2010 11:28 am

here is some information about it:

wiki link
 
danieln
just joined
Posts: 3
Joined: Thu Apr 28, 2016 4:51 pm

Re: why? API disable hotspot user fail

Thu Apr 28, 2016 5:11 pm

hi, i'm new in the forum, First, excuse me for my English, i speak Spanish. Second, i'm making an api in VB, i can add user perfectly but i want delet users. these are the instructions are those that have tried to do, but i can't do it. hepl me please

ConexionMK.Send("/ip/hotspot/user/remove", True)
ConexionMK.Send("=name=" & admin, False)
'ConexionMK.Send("=id=" & "=" & 3, True)