Community discussions

 
nihatkusneli
just joined
Topic Author
Posts: 2
Joined: Fri Apr 13, 2018 7:55 am

RouterOs Api Script

Fri Mar 29, 2019 8:10 am

Hi,
In the following figure, the script I wrote via routeros api gives an error. What's the right way?
$API->write('/ip/hotspot/cookie/remove');
$API->write('=user=155548745');
$OKU=$API->read(false);
$ARRAY = $API->parseResponse($OKU);
print_r ($ARRAY);

Error Code :
[code][!trap] => Array ( [0] => Array ( [message] => no such command prefix ) )
Thanks...
 
User avatar
BlackVS
Member Candidate
Member Candidate
Posts: 171
Joined: Mon Feb 04, 2013 7:00 pm
Contact:

Re: RouterOs Api Script  [SOLVED]

Wed Apr 03, 2019 12:01 pm

Try remove by id not by name.
In terminal of WinBox
/ip hotspot cookie remove ?
I see
Remove specified item (or several items).
<numbers> -- List of item numbers
i.e. very probably it needs numbers i.e. I think ids, something like
$API->write('=.id=*ABCDEF');
Sure you need find value of field ".id" for required user first...
In terminal it is command like:
:put [/ip hotspot cookie find user="155548745"]
Or try condition:
$API->write('?=user=155548745');
From API docs unclear if this work in such way
 
nihatkusneli
just joined
Topic Author
Posts: 2
Joined: Fri Apr 13, 2018 7:55 am

Re: RouterOs Api Script

Sat Sep 07, 2019 9:57 pm

Thanks...

Who is online

Users browsing this forum: No registered users and 6 guests