Another RouterOS API Delphi Client

Yes, you were right. When I debugged it I found out that it sends replies but never ends because there is no !done. But even if I put /cancel at the end, it never gets to this cancel.

mikrotik.Send("/interface/monitor-traffic");
mikrotik.Send("=interface=ether1");
mikrotik.Send("/cancel", true);

… is there any workaround?

I’ve used as a source this site http://wiki.mikrotik.com/wiki/API_in_C_Sharp.
Do you know maybe how to change the code so it would not always wait for this !done?

you should execute your query, read necessary results and then stop it by executing “/cancel”

Gostaria de sabe como removo um linha no firewall, no ssh eu uso assim como faz o mesmo na api-delphi


“I would like to know how to remove a line in the firewall, I use ssh in and do the same in-api delphi”


/ip firewall nat remove [/ip firewall nat find src-address=10.0.0.1]

There might be a shorter way, but I update address list by getting e.g.

/ip/firewall/address-list/print','?list=mylist'

Then parse the results an get the .id of the record I want to change.
Then do a

'ip/firewall/address-list/remove','=.id='+theid

Hope it helps.

Ekkas

this basically is the way how you do that.

get the ID of the entry and remove by ID.

when I do a ‘query’ from terminal window:
/tool user-manager user print count-only

I get an instant response, in this case 6925

But when I run API command:
Res:=ROS.Query([‘/tool/user-manager/user/print’,‘=count-only’],True);

Then it takes about 10 seconds to complete.

  • Am I doing the API command wrong?
    is it just how API works?
    Is it a possible new feature request?

Thanks
Ekkas

do you have the same result in case of API?..

What do you mean?
Terminal= instant

API =very slow

I mean, what do you receive in API response?
in both v4.2 and v5.0rc10 I get empty response if I try to use ‘=count-only’ (I’m checking /ip/address/print) - seems like it doesn’t work at all

Using your APItest:


Connected!
Version: 4.16
!done=
=ret=7145

================

then you should write to support@, I believe :slight_smile:

p.s. please mention that it doesn’t work for /ip/address/print =)

I’ll write to support.

It works for me on ip (ROS 4.16):
API2.JPG

And in ROS 5rc9:
API3.JPG

argh, it’s returned in the same sentence as ‘!done’, so “Query & Listen” do not see it %) “Query & Get All” works fine, sorry for inconvenience :slight_smile:

No Problem. I always use getall. lol


Maybe you can help me with this one:
http://forum.mikrotik.com/t/api-and-date-filter/45109/1

if i remember correctly, then some long time ago getall was an alias for print, so you get same stuff using getall or print commands using API, and for details you have to use =detail= (not so old change)

please correct the docs: http://wiki.mikrotik.com/wiki/API#Command_description

if .proplist is absent, > all possible properties are included> , even those that have slow access time (such as file contents and perfomance counters). Thus use of .proplist is encouraged. Omission of .proplist may have high perfomance penalty.

thanks for pointing that out, wording has been updated.

huh, from the same place:

arguments that modify list of returned properties (> detail> , breif, …) have > no effect > in the API

:slight_smile:

edit-search-done. :blush: