why? API disable hotspot user fail

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 :frowning:

 mikrotik.Send("/ip/hotspot/user/set/=.name=user1=disabled=yes", True)

any advice ?
thanks

http://forum.mikrotik.com/t/api-acl-control/29390/1

thanks for replay ,
I have tested this code, but also failed :confused:

        mikrotik.Send("/ip/hotspot/user/print", True)
        mikrotik.Send("=.proplist=.id", True)
        mikrotik.Send("?comment=teste", True)

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 ?

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)



and what if just

mikrotik.Send("/ip/hotspot/user/print", False)

?..

I have used the search by name and comment and all of them do not work .

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)

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 :confused:

thanks .

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 .





please quote exact code and exact response

sorry for disturbing you :frowning:

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 :unamused:

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 :smiley:
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 :smiley:

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.

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

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.

super!

maybe, it should be mentioned in the Wiki? =)

here is some information about it:

wiki link