Another RouterOS API Delphi Client

Are you running your app directly from the editor?

If so, it’s possible that you need to whitelist the editor in your computer’s firewall - it may currently be preventing the editor from making outgoing connections.

I run it from the editor and also from windows exe file
Both of them face with the problem
I traced it and found the problem:
In delphi XE4 string type is default to WideString, but in delphi 7 it is AnsiString
I changed SetVarSin and GetAddr Functions Parameters (in sswin32 file) String–> AnsiString
and now it works

Hi,

anybody has experience for installing RosAPI & Synapse under XE5 ?

regards

Armand

Please, take me edited sswin32 file or say how edit sswin32 file(plaese edited code)? i try edit with your recomendation, but this is now work for me :frowning: Thank you!

Thank you for share this api.

For those that are facing a endless loop when for connection break , I resolve including :
or (fsock.LastError <> 0)

here:
function TRosApiClient.RecvSentence(const Wait: Boolean; out se: TROSAPISentence): Boolean;
var
p: Integer;
w: AnsiString;
begin
repeat
…
until (w <> ‘’) or (fsock.LastError <> 0);

Environment: win7 x64 , delphi 2009, last synapse version

Awesome thank you!!!
Yes I’ve had this many times before, glad there is a fix. :slight_smile:
Thought it was problem in Synapse.

[dcc32 Fatal Error] MainForm.pas(7): F2613 Unit '..\Common\RouterOSAPI.pas' not found.

Delphi XE8 2015.1

then… use correct path to RouterOSAPI.pas :slight_smile:

p.s. that file is not in APITest, have you downloaded it separately?

Edit: APITest.dpr

program APITest;

uses
  Forms,
  MainForm in 'MainForm.pas' {frmMain},
  RouterOSAPI in 'RouterOSAPI.pas';



[dcc32 Fatal Error] RouterOSAPI.pas(67): F2613 Unit 'blcksock' not found.
[dcc32 Fatal Error] RouterOSAPI.pas(67): F2613 Unit 'synautil' not found.
[dcc32 Fatal Error] RouterOSAPI.pas(67): F2613 Unit 'synsock' not found.
[dcc32 Fatal Error] RouterOSAPI.pas(67): F2613 Unit 'synacode' not found.

those are from Ararat Synapse

Hi all,
I have this error :

tr_mkrouter.msend /login
tr_mkrouter.msend /login
tr_mkrouter.msend =name=apiuser
tr_mkrouter.msend =password=2010 <-----{My clear password}
tr_mkrouter.msend =response=39582d42fb88ca42ae0958e46b24e318
tr_mkrouter.open opening router error = !trap=message=cannot log in
Delphi XE8.

Thanks for help

wrong topic. my client does not have any ‘msend’ command. also, plain password should not be sent over network (it’s insecure!), you’re doing something wrong

Oh thinks :slight_smile:
How do I run this command with api?:

/tool user-manager user  remove [find username=demo]

http://forum.mikrotik.com/t/remove-active-user-hotspot-php-api/23834/1

Hello, Chupaka!
Thank you for great api))
I have a question:
How can i write the query ‘/ip hotspot active print detail where user=username’?

I still can’t understand how to use symbols *, ?, ., and =
Can you explain the meaning of each symbol and the rules of queries?

Thank you very much!))

Command should be something like:
pa[0] := ‘/ip/hotspot/active/print’;
pa[1] := ‘?user=username’;

All details of the command structure are described in the wiki:
http://wiki.mikrotik.com/wiki/Manual:API

There is no explanations about signs (* = ? .)

Could you please write a correct ROS.Query() for CLI command “/ip hotspot active print detail where user=username”?
I need to get mac-address of username from the result, i tried different variants, but unsuccessful ((

Thank you.

http://wiki.mikrotik.com/wiki/Manual:API#Queries

as docmarius said, it should be something like

/ip/hotspot/active/print
=.proplist=mac-address
?user=username

what result/error do you have?

I’m sorry for silence, I’m just resumed my work.

So, I get nothing with this query… I suppose I do something wrong…

For example, I want to see in Label1 information about IP and MAC of active user FFF. In buttonclick I write:

procedure TForm1.btn1Click(Sender: TObject);
var
  Res: TRosApiResult;
begin
  Res := ROS.Query(['/ip/hotspot/active/print', '=.proplist=mac-address', '?user=fff'], True);
  while not res.Eof do
  begin
        if Res.Trap then
          ShowMessage('Trap: ' + ROS.LastError)
        else
          begin
            label1.Caption := 'user: ' + Res['user'] + #13#10 + 'address: ' + Res['address'] + #13#10 +
                        'mac: ' + Res['mac-address'];
        end;
          res.Next;
  end;
      Res.Free;
end;

And there is nothing… No results, no errors.
Please, help me with this query))

It’s working!!!)))) I’m sorry, there was no active users))
Thank you very-very much!))

bwahaha, glad to hear that =)