Community discussions

 
rodolfo
Long time Member
Long time Member
Topic Author
Posts: 539
Joined: Sat Jul 05, 2008 11:50 am

Complete DELPHI API client: update 4

Fri Jan 02, 2009 1:19 pm

update 4:
- rewritten mrecv functions to avoid errors when output contains #0
- faster output reducing timer interval between two sentences
- now empty password are allowed
- added output to log file

update 3:
- created wiki page http://wiki.mikrotik.com/wiki/API_Delphi
- minor updates in api_studio_104

The download contain the source code of a Delphi class (and of a demo application) to simply interface the routerOS API.
Please refer to http://wiki.mikrotik.com/wiki/API_Delphi for more informations.

LAST VERSION
api_studio_108.zip
Please report me suggestions, errors and so on.

Thanks.
You do not have the required permissions to view the files attached to this post.
Last edited by rodolfo on Sun Apr 05, 2009 11:52 am, edited 12 times in total.
rodolfo
IZ0UQV
 
cmit
Forum Guru
Forum Guru
Posts: 1552
Joined: Fri May 28, 2004 12:49 pm
Location: Germany

Re: Complete DELPHI API client

Thu Jan 08, 2009 6:53 pm

Hi Rodolfo,

the included compiled EXE does work OK here. Compiling the source with Delphi 6 works (after hacking in a replacement for PosEx, which is not there in Delphi 6), but the tool hangs during opening the connection to the router. Actually it stalls in tr_mkrouter.open while waiting for the response for the first "/login" command. That's in this line:
hash:=ex_val(res,'ret','',false);
Any idea?
Best regards,
Christian Meis
 
cmit
Forum Guru
Forum Guru
Posts: 1552
Joined: Fri May 28, 2004 12:49 pm
Location: Germany

Re: Complete DELPHI API client

Fri Jan 09, 2009 1:16 am

Nevermind. Seems to be a bug with the version of the synapse library contained in your download.
I checked out the latest revision from SVN (rev. 95) and it started working right away ;-)
Best regards,
Christian Meis
 
xbaha
Member Candidate
Member Candidate
Posts: 111
Joined: Fri Mar 09, 2007 12:16 pm

Re: Complete DELPHI API client

Tue Jan 13, 2009 9:27 am

where did you download synapse from?
 
rodolfo
Long time Member
Long time Member
Topic Author
Posts: 539
Joined: Sat Jul 05, 2008 11:50 am

Re: Complete DELPHI API client

Tue Jan 13, 2009 5:03 pm

Main site http://www.ararat.cz/synapse/doku.php/download
Last version: https://synalist.svn.sourceforge.net/sv ... ist/trunk/

cmit: thanks, I updated the main thread with last library
rodolfo
IZ0UQV
 
xbaha
Member Candidate
Member Candidate
Posts: 111
Joined: Fri Mar 09, 2007 12:16 pm

Re: Complete DELPHI API client

Wed Jan 14, 2009 4:24 am

i have tried this software its great, i would like to know why it doesnt handle streaming data from the router,
for example: i am trying this command /tool ping 192.168.100.1

one time i get this:
14/01/2009 05.21.50 - 142 -
14/01/2009 05.21.50 - info 102 - EXECUTE= /tool ping 192.168.100.1
14/01/2009 05.21.50 - info 103 - =!done=

and the other time i get this (why?) :
14/01/2009 05.23.57 - 142 -
14/01/2009 05.23.57 - info 102 - EXECUTE= /tool ping 192.168.100.1
14/01/2009 05.23.57 - #ERROR# 10004 - 192.168.100.1 tr_mkrouter.mrecv !trap==!trap=message=no such command=
14/01/2009 05.23.57 - info 103 - =!trap=message
=no such command=
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6283
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: Complete DELPHI API client

Thu Jan 15, 2009 12:37 pm

ping works differently using api, than usual ping in terminal

on api, you get result of how many pings sent, and how many you received back, so you have to set =count=<some number> allways

or it will run until you issue cancel command to cancel your ping.
 
pedja
Long time Member
Long time Member
Posts: 684
Joined: Sat Feb 26, 2005 5:37 am

Re: Complete DELPHI API client

Thu Jan 15, 2009 9:06 pm

I have Delphi 5 and could not compile without some tweaking:

- as StrUtil unit is missing. I found it at http://www.koders.com/delphi/fidDF48A5F ... x?s=delphi, copied code from site and saved it as StrUtils.pas in project directory.

- Sleep() function was not available in uUtils.pas, so I had to add Windows in uses in this unit

- in uMain.pas I had to remove Variants form uses


Then project compiled, and executable works fine. Good job.
 
pedja
Long time Member
Long time Member
Posts: 684
Joined: Sat Feb 26, 2005 5:37 am

Re: Complete DELPHI API client

Thu Jan 15, 2009 10:08 pm

I tried /ping =address=10.50.10.13 =count=3 and it works ok, but returns just number of successful ping. Is there an option to get all ping details?
 
pedja
Long time Member
Long time Member
Posts: 684
Joined: Sat Feb 26, 2005 5:37 am

Re: Complete DELPHI API client

Thu Jan 15, 2009 11:13 pm

Response string is not parsed properly.

It is very strange that = is uset to delimiter both items and item name and value. It is very tricky to parse.

Here is an example:

=!re=.id=*6=name=wan-adsl=mtu=1500=mac-address=00:41:05:4F:82:DA=arp=enabled=disable-running-check=yes=auto-negotiation=yes=full-duplex=yes=cable-settings=default=speed=100Mbps=running=yes=slave=no=comment==disabled=no==

It's hard to distinguish which part is item name and which one is item value.

Is it possible to change these delimiters?
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6283
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: Complete DELPHI API client

Fri Jan 16, 2009 9:37 am

if you try other example and sniff for actual API traffic you will notice that there is symbol in between the lines and your output of :
=!re=.id=*6=name=wan-adsl=mtu=1500=mac-address=00:41:05:4F:82:DA=arp=enabled=disable-running-check=yes=auto-negotiation=yes=full-duplex=yes=cable-settings=default=speed=100Mbps=running=yes=slave=no=comment==disabled=no==

actually looks more like:
=!re
=.id=*6
=name=wan-adsl
=mtu=1500
=mac-address=00:41:05:4F:82:DA
=arp=enabled
=disable-running-check=yes
=auto-negotiation=yes
=full-duplex=yes
=cable-settings=default
=speed=100Mbps
=running=yes
=slave=no
=comment=
=disabled=no
==
now, compare what i get when issue the command in my implementation:
!re
=.id=*1
=name=ether1
=mtu=1500
=mac-address=00:0C:42:2D:80:06
=arp=enabled
=auto-negotiation=yes
=full-duplex=yes
=speed=100Mbps
=running=yes
=slave=no
=comment=
=disabled=no
as far as i can remember - each line have value preceding the line, that shows how many symbols there is in the line, hence, always it will be like =some-arg=value and value will be everything till the end of line after 2nd "="

either fix that in the code or ask someone to do that for you
 
pedja
Long time Member
Long time Member
Posts: 684
Joined: Sat Feb 26, 2005 5:37 am

Re: Complete DELPHI API client

Fri Jan 16, 2009 7:32 pm

Right! :) Silly me, I forgot that I am not getting data directly from Mikrotik but from intermediate layer which was messed up. I got it now. Thanks.
 
rodolfo
Long time Member
Long time Member
Topic Author
Posts: 539
Joined: Sat Jul 05, 2008 11:50 am

Re: Complete DELPHI API client

Sat Jan 17, 2009 6:20 pm

I entierely rewritten the library, taking in account the correct numbering of the send commands and !done received.

Now commands link /tool/ping =address=19.19.18.17 works well, as the others command.

Thanks for suggestions.

You could download from main post.

Rodolfo
rodolfo
IZ0UQV
 
rodolfo
Long time Member
Long time Member
Topic Author
Posts: 539
Joined: Sat Jul 05, 2008 11:50 am

Re: Complete DELPHI API client: update 3

Sun Jan 18, 2009 1:13 pm

I published a wiki page and update a little the code.
thanks
rodolfo
IZ0UQV
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8305
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Complete DELPHI API client: update 3

Mon Mar 23, 2009 11:04 am

oops, example application do not work with empty password =)
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8305
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Complete DELPHI API client: update 3

Wed Apr 01, 2009 1:26 am

also, this class do not work correctly with replies, containing #0 in parameter value, because it is designed to think that #0 is the end of sentence. so, for example, I cannot get normal list of my DHCP server leases, where Agent-Circuit-ID is MAC address of switch and contains #0 in it

I see something like the following:
=!re=.id=*3952
<...text here...>
=src-mac-address=00:1E:58:49:EF:F1
=agent-circuit-id=
==agent-remote-id
=
=XIпс=radius
=true
=dynamic
=tru=
=blocked=false
p.s. why is this implementation so slow?.. mine is based on Synapse too, and prints output much faster... I hope some day I will public it, I just began to code...
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.
 
rodolfo
Long time Member
Long time Member
Topic Author
Posts: 539
Joined: Sat Jul 05, 2008 11:50 am

Re: Complete DELPHI API client: update 4

Sun Apr 05, 2009 11:54 am

Hi Chupaka, thanks for suggestions.
I have updated the code and:
1. empty passwords could be allowed
2. I rewritten mrecv function. Now I have a better implementation of the protocol and #0 char works well
3. I reduced a lot the timer interval between the receive of two sentences and the output is much faster.
rodolfo
IZ0UQV
 
tkwak
newbie
Posts: 45
Joined: Thu Jan 19, 2006 5:11 pm

Re: Complete DELPHI API client: update 4

Sat May 23, 2009 4:21 pm

Dear rodolfo:

I am using the API to develop an control software as 'Mini-winbox', now i face an trouble with the api.
when i want to issuse the command like '/ip/router/unset .id=*2 routing-mark' , i get get an argument error.

How to using unset command through RouterOS API?

I have ask this question 1 year before, but no body can answer me as well, Would u like to help me on this ? Thank u very much~!
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8305
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Complete DELPHI API client: update 4

Sat May 23, 2009 8:27 pm

did you asked support@mikrotik.com ?
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.
 
tkwak
newbie
Posts: 45
Joined: Thu Jan 19, 2006 5:11 pm

Re: Complete DELPHI API client: update 4

Sun May 24, 2009 8:07 am

ya,,, not yet ,i think i need to report to them too, thx Chupaka
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8305
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Complete DELPHI API client: update 4

Sun May 24, 2009 3:19 pm

please post here any news about unset =)
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.
 
geraldospint
just joined
Posts: 3
Joined: Fri Jun 19, 2009 11:54 pm

Re: Complete DELPHI API client: update 4

Fri Jun 19, 2009 11:59 pm

Hello,
how to send this comando to router using api "/interface wireless access-list add mac-address=00:11:22:33:44:55 interface=AP-1 authentication=yes forwarding=no comment= TESTE"
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8305
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Complete DELPHI API client: update 4

Sat Jun 20, 2009 7:26 pm

Hello,
how to send this comando to router using api "/interface wireless access-list add mac-address=00:11:22:33:44:55 interface=AP-1 authentication=yes forwarding=no comment= TESTE"
hm...
/interface/wireless/access-list/add
mac-address=00:11:22:33:44:55
interface=AP-1
authentication=yes
forwarding=no
comment= TESTE
should work
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.
 
tkwak
newbie
Posts: 45
Joined: Thu Jan 19, 2006 5:11 pm

Re: Complete DELPHI API client: update 4

Wed Jul 15, 2009 2:14 pm

It works, you have to specify value-name
for example
/ip/route/unset
=.id=*1
=value-name=routing-mark
 
gcakici
Frequent Visitor
Frequent Visitor
Posts: 60
Joined: Thu Feb 23, 2006 11:44 am

Re: Complete DELPHI API client: update 4

Wed Sep 02, 2009 11:08 pm

Hi Rodolfo,

I've download your last version of API and try to work it out on Delphi 2009. It just don't work at all. MD5 library has been changed some how https://forums.codegear.com/thread.jspa ... eID=114098. Synapse library has also throwing some problems when i try to use.

As you can understand i'm not a Delphi fun but i need to work with your library. It will be much better if you can update your downloadable file with the proper .pas files.

Thanks for your work already.

Gokalp
 
ekkas
Long time Member
Long time Member
Posts: 562
Joined: Mon Sep 26, 2005 1:01 pm
Location: South Africa

Re: Complete DELPHI API client: update 4

Wed Sep 30, 2009 4:31 pm

I would also love to use it, but can't even compile in D2009.
Are you still updating these units from time to time or plan to update to D2009?

thanks

Ekkas
 
rodolfo
Long time Member
Long time Member
Topic Author
Posts: 539
Joined: Sat Jul 05, 2008 11:50 am

Re: Complete DELPHI API client: update 4

Thu Oct 01, 2009 1:48 pm

I will try at the beginning of next week.
rodolfo
IZ0UQV
 
ekkas
Long time Member
Long time Member
Posts: 562
Joined: Mon Sep 26, 2005 1:01 pm
Location: South Africa

Re: Complete DELPHI API client: update 4

Thu Oct 01, 2009 3:24 pm

Thanks a lot. We'll all appreiate it.
 
mosman
just joined
Posts: 1
Joined: Sat Dec 05, 2009 1:46 pm

Re: Complete DELPHI API client

Sat Dec 05, 2009 2:09 pm

ping works differently using api, than usual ping in terminal

on api, you get result of how many pings sent, and how many you received back, so you have to set =count=<some number> allways

or it will run until you issue cancel command to cancel your ping.
Well, is there any way to get ping response delay in ms? Is there an extra parameter to "/ping" to fetch full information?

Is there an way to set environment variables via API?

Why when I run scripts via API /system/script/run the environment variables remain unchangend?


Regards, Andrei.
 
manuelritter
newbie
Posts: 38
Joined: Wed Sep 16, 2009 4:10 pm

Re: Complete DELPHI API client

Tue May 18, 2010 9:42 am

ping works differently using api, than usual ping in terminal

on api, you get result of how many pings sent, and how many you received back, so you have to set =count=<some number> allways

or it will run until you issue cancel command to cancel your ping.
Well, is there any way to get ping response delay in ms? Is there an extra parameter to "/ping" to fetch full information?
Hello,

I am also very interested in full ping information from API.
Is there any way to fetch full information or is it possible to add in future versions?

Greetings
Manuel Ritter
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6283
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: Complete DELPHI API client: update 4

Tue May 18, 2010 1:40 pm

lets wait for 5.0beta3 public release

in wiki you already can see new output format

http://wiki.mikrotik.com/wiki/API_comma ... _and_newer

edit: it will not change for v4 thought.
 
leonardocx
just joined
Posts: 3
Joined: Sat Sep 01, 2012 5:50 pm

Re: Complete DELPHI API client: update 4

Sat Sep 01, 2012 5:58 pm

I wonder if there is to build this api delphi XE2, I'm doing some tests and conseigo run this application in delphi 7 but not in XE2 realized ..... update the MD5 and sokets, according to the ICS v7. but the application returns me this message ...
01/09/2012 11:56:58 - info 103 - connecting to 192.168.2.100
09.01.2012 11:56:58 - DEBUG 11001 - 192.168.2.100 tr_mkrouter.msend / login
09.01.2012 11:56:58 - DEBUG 11001 - 192.168.2.100 tr_mkrouter.msend / login
09.01.2012 11:56:58 - DEBUG 11001 - tr_mkrouter.msend = 192.168.2.100 name = admin
09.01.2012 11:56:58 - DEBUG 11001 - = 192.168.2.100 tr_mkrouter.msend response = 0072305e1275f4e0584561fb682e455939
01/09/2012 11:56:58 - # ERROR # 10008 - 192.168.2.100 tr_mkrouter.open opening router error =! Trap = message = can not log in
even with a valid password, the logs are OK RB disendo that there was a connection attempt api but login error!
 
pvidal
newbie
Posts: 28
Joined: Fri May 11, 2012 6:18 pm
Location: Buenos Aires, Argentina
Contact:

Re: Complete DELPHI API client: update 4

Wed Oct 31, 2012 11:21 pm

Hello! I just downloaded the API for Delphi. I tested many commands with the example app but /system/reboot doesn't work.

Any clue?

Thanks in advance!
Pablo J. Vidal
Certified MikroTik Consultant
http://www.snwifi.com.ar
Image
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8305
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Complete DELPHI API client: update 4

Fri Nov 02, 2012 1:08 pm

/system/reboot works fine for me. at least on 6.0rc3 =)
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.
 
User avatar
DogHead
Member Candidate
Member Candidate
Posts: 194
Joined: Thu Jan 03, 2008 9:36 pm
Location: Anywhere you want me to be

Re: Complete DELPHI API client: update 4

Thu Nov 15, 2012 5:39 pm

/system reboot in 5.21 requires interactive confirmation as does /system upgrade

/system auto-upgrade requires interactive password

Using ROS scripting you cannot respond to these requests, rendering all scripts that use these commands useless. The right way to fix the problem is eliminate the interactive confirmation, or bypass it when called from a script rather than the console. This would take work by MT.

Alternatively, could someone write a binary that can run on a router that can deal with this? I am not a coder so don't know what is involved.
WOOF BANG!
 
biomesh
Member Candidate
Member Candidate
Posts: 139
Joined: Fri Feb 10, 2012 8:25 pm

Re: Complete DELPHI API client: update 4

Thu Nov 15, 2012 6:58 pm

/system reboot in 5.21 requires interactive confirmation as does /system upgrade

/system auto-upgrade requires interactive password

Using ROS scripting you cannot respond to these requests, rendering all scripts that use these commands useless. The right way to fix the problem is eliminate the interactive confirmation, or bypass it when called from a script rather than the console. This would take work by MT.

Alternatively, could someone write a binary that can run on a router that can deal with this? I am not a coder so don't know what is involved.
/system reboot works fine for me in a script on a 5.21 x86 box
 
User avatar
DogHead
Member Candidate
Member Candidate
Posts: 194
Joined: Thu Jan 03, 2008 9:36 pm
Location: Anywhere you want me to be

Re: Complete DELPHI API client: update 4

Fri Nov 16, 2012 2:50 am

On mipsbe 411GL and 433 we get a prompt for Are you sure?

Scripts fail every time on this. Cannot put in a Y response.
WOOF BANG!
 
biomesh
Member Candidate
Member Candidate
Posts: 139
Joined: Fri Feb 10, 2012 8:25 pm

Re: Complete DELPHI API client: update 4

Fri Nov 16, 2012 5:00 am

I can try on a 751G tomorrow.

Sent from my Nexus 7 using Tapatalk 2
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8305
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Complete DELPHI API client: update 4

Fri Nov 16, 2012 12:17 pm

"/system reboot" in Terminal always required confirmation, and at least since long time ago it's not requiring it in scripts. check that your script has necessary permissions
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.
 
biomesh
Member Candidate
Member Candidate
Posts: 139
Joined: Fri Feb 10, 2012 8:25 pm

Re: Complete DELPHI API client: update 4

Fri Nov 16, 2012 4:33 pm

Works as expected on a 751G - I would have to agree with Chupaka and make sure the permissions are correct.

If you are using an API to send these commands, they are probably being interpreted as being interactive. I would try to send the commands via the script interface. This could be done via a rsc file or just run the /system script command to create the scripts to be run and either execute the script via /system script run or add a scheduler entry.
 
stbox
just joined
Posts: 3
Joined: Sat Nov 24, 2012 4:11 pm

Re: Complete DELPHI API client: update 3

Sat Nov 24, 2012 6:45 pm

hi
i want to send a command Instead of parametr in api
/ppp/active/remove
=.id=*25
i want send a command like this
=id.=[find name=ppp1]
this command not work

totally i can this work with api ?
if true
please help
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8305
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Complete DELPHI API client: update 4

Mon Nov 26, 2012 5:52 pm

you need first find necessary ids, then remove them
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.
 
esmit61
just joined
Posts: 4
Joined: Sun Sep 15, 2013 9:58 am

Re: Complete DELPHI API client: update 4

Sun Sep 15, 2013 10:01 am

Hi,
I want to disconnect a vpn user (named "test") and send this command:
/ppp/active/remove =[find name=test]

but it doesn't disconnect :(
would you please help me how should i write the command?

Regards,
esmit
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8305
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Complete DELPHI API client: update 4

Tue Sep 17, 2013 1:02 am

first
/ppp/active/print
=.proplist=.id
?name=YOUR_NAME_HERE
then
/ppp/active/remove
=.id=YOUR_ID_HERE
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.
 
esmit61
just joined
Posts: 4
Joined: Sun Sep 15, 2013 9:58 am

Re: Complete DELPHI API client: update 4

Sat Sep 21, 2013 11:25 pm

So thanks, It worked.
I have another problem,
RouterOs.pas works with delphi 7, but when i run it with delphi XE4 it dousn't work
I get error in RouterOs.Connect. it returns False and RouterOS.LastError returns: "Host not found" !!!
i can ping the host and user pass are correct. furthermore i can connect with delphi 7 !!!
Please Help me
sorry for my English
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8305
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Complete DELPHI API client: update 4

Tue Sep 24, 2013 7:19 pm

Sorry, I can't help with that. You can check my client here - it works with Delphi 2009, probably it will work with XE4
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.
 
DimebagDarrell
just joined
Posts: 7
Joined: Fri Jun 07, 2013 4:15 am

Re: Complete DELPHI API client: update 4

Wed Jan 06, 2016 9:54 pm

Delphi X
[dcc32 Error] md5.pas(343): E2064 Left side cannot be assigned to
[dcc32 Fatal Error] api_studio.dpr(46): F2063 Could not compile used unit 'md5.pas'
Error:
function GetMD5(Buffer: Pointer; BufSize: Integer): string;
var
    I          : Integer;
    MD5Digest  : TMD5Digest;
    MD5Context : TMD5Context;
begin
    I := 0;
    for I := 0 to 15 do
    		Byte(MD5Digest[I]) := I + 1;  >>>>>>>>>> ERROR
    MD5Init(MD5Context);
    MD5UpdateBuffer(MD5Context, Buffer, BufSize);
    MD5Final(MD5Digest, MD5Context);
    Result := '';
    for I := 0 to 15 do
        Result := Result + IntToHex(Byte(MD5Digest[I]), 2);
end;
 
User avatar
BartoszP
Forum Guru
Forum Guru
Posts: 1703
Joined: Mon Jun 16, 2014 1:13 pm
Location: Poland

Re: Complete DELPHI API client: update 4

Wed Jan 06, 2016 10:02 pm

What is Byte() ?
Real admins use real keyboards.
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8305
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Complete DELPHI API client: update 4

Thu Jan 07, 2016 1:38 pm

What is Byte() ?
a type cast?..
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.
 
User avatar
BartoszP
Forum Guru
Forum Guru
Posts: 1703
Joined: Mon Jun 16, 2014 1:13 pm
Location: Poland

Re: Complete DELPHI API client: update 4

Thu Jan 07, 2016 2:03 pm

Just asking to confirm. I have not used Delphi for ages.
I is Integer, Byte is byte wide so how to assign integer to byte ? .... IMHO should be:
Byte(MD5Digest[I]) := Byte(I + 1);
What type is MD5Digest ?
Maybe it is better to convert I+1 directly to MD5Digest ?

This could help:
http://stackoverflow.com/questions/4161 ... ssigned-to
Real admins use real keyboards.
 
jeremycoulter
just joined
Posts: 5
Joined: Mon Jul 20, 2015 12:51 am

Re: Complete DELPHI API client: update 4

Tue Mar 28, 2017 9:20 am

I ran into this problem yesterday too when converting from an old Delphi 2007 project to Delphi 10.2.
Fortunitly i have had this problem before and all you need to do is the following:

In the OPEN() function, change
enpa:=encode_password(password,hash);
to
enpa:=encode_password(AnsiString(password),AnsiString(hash));
Then change the encode_password function to the followiing:
function TRouterOS.encode_password(passw, hash: Ansistring): string;
var
  ac, temp: Ansistring;
  pc: Array of ANSIChar;
  i, lp: integer;
begin
 if (hash<>'') and (passw<>'')
  then begin
        lp:=length(passw);
        setlength(pc,1+lp+16);
        pc[0]:=#0;
        move(passw[1],pc[1],lp);
        for i:=0 to 15
         do begin
             ac:=copy(hash,i*2+1,2);
             if ac<>''
              then pc[1+lp+i]:=AnsiChar(StrToInt('$' + ac));
            end;
        temp:=GetMD5(@pc[0], 1+lp+16);
       end
  else begin
        temp:='#error#';
       end;
 result:=lowercase(temp);
end;
Also update to the latest OverByte ICS controls and I also downloaded, and also head over to http://delphi.cz/img/synapseandroid/synapse_2.zip to get an updated Synapse library. It will talk about being for Android and iOS, but I just took the files in the "Lib" folder in the zip file and replaced the ones I had in my old Synapse folder.

Hope that helps.

Jeremy
 
marcelosantos
just joined
Posts: 4
Joined: Thu Mar 30, 2017 9:02 pm

Re: Complete DELPHI API client: update 4

Wed Apr 05, 2017 5:47 pm

Hello, I have the following need

I need to print / list all my PPP secrets that are not online

I can list all the names with the code
/ppp/secret/print
=.proplist=name
The answer at the exit is
!re=name=marcelo
!re=name=xxxxxx
....
I can't do is get these names and search with the following script
:global list ""; 
:foreach i in [/ppp active find] do={:if ([:find \
[/ppp active get $i name] "m"]=0) do={:set list ($list . "," . $i);}}; \
/ppp active print detail without-paging from  $list; 
change "m" for names

Can someone help me?
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8305
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Complete DELPHI API client: update 4

Thu Apr 06, 2017 2:11 pm

You first get all ppp secrets with "/ppp/secret/print", then get all online secrets with "/ppp/active/print", then you process the lists in your Delphi program, by excluding second list from the first :)
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.
 
marcelosantos
just joined
Posts: 4
Joined: Thu Mar 30, 2017 9:02 pm

Re: Complete DELPHI API client: update 4

Thu Apr 06, 2017 10:27 pm

True, I spent so much time trying to do with script that I did not think of using logic in delphi

Thank's
 
User avatar
Ishtiaque
newbie
Posts: 46
Joined: Sat Jul 30, 2016 5:17 pm
Location: Bangladesh
Contact:

Re: Complete DELPHI API client: update 4

Fri Jun 02, 2017 1:41 am

You first get all ppp secrets with "/ppp/secret/print", then get all online secrets with "/ppp/active/print", then you process the lists in your Delphi program, by excluding second list from the first :)
Dear
Please Help me for PCQ Mechanism , and please See my detailed question here Please :( viewtopic.php?f=2&t=28537
Learner Of MiKroTiK Please Help Me
 
bgkitlua
just joined
Posts: 1
Joined: Tue Jul 04, 2017 3:37 pm

Re: Complete DELPHI API client: update 4

Tue Jul 04, 2017 3:43 pm

Please help-me, i'm creating a software with delphi api, but i can't download a file of RouterBoard. How i can do this?
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8305
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Complete DELPHI API client: update 4

Tue Jul 04, 2017 5:59 pm

What file?..
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.
 
coopersoft
just joined
Posts: 1
Joined: Wed Dec 20, 2017 7:58 pm

Re: Complete DELPHI API client: update 4

Fri Dec 22, 2017 1:00 am

Hello, I need to connect to mikrotik through Delphi 10.1 Berlin, and I'm not getting it, can anyone help me?
Units do not work.
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8305
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Complete DELPHI API client: update 4

Fri Dec 22, 2017 11:47 am

Hello, I need to connect to mikrotik through Delphi 10.1 Berlin, and I'm not getting it, can anyone help me?
Units do not work.
what exactly is not working? some errors or something?..
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.
 
User avatar
hendrojio
just joined
Posts: 1
Joined: Tue Dec 19, 2017 2:12 am
Location: indonesia
Contact:

Re: Complete DELPHI API client: update 4

Fri Dec 29, 2017 6:39 pm

helo, mr. Chupaka
I'm a new in API delphi. I try to make my self program,
First I want to save my file from simple queue in folder of RB, I did it and it work in mikrotik terminal, the command are:
/queue simple print rate file=<name-file>
That's what I want, just save a file and not to show the result of queue simple rate.
So I run command from API Delphi, of course it work as in the memo.text show the result result queue simple rate (but I didn't want it because it of course make my procces program goes slowly), but that's never save a file in folder files of RB.
My command in delphi: 1) /queue/simple/print 2)=rate 3)=file=<myfile>

second problem is, how can I download that file from RB to my folder in Windows laptop?
I want do that with interval in 5s (save a file in RB folder then download to laptop , because I will put them in my database).
I hope you can solve my problem.
Thank you.
keep on doing and moving
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8305
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Complete DELPHI API client: update 4

Wed Jan 03, 2018 9:27 am

Don't do it that way. It's completely wrong.

Just receive data directly via API, instead of using the microscope for hammering nails.

Get /queue/simple/print data and use it directly in your program, without intermediate files.
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.
 
hermeson
just joined
Posts: 16
Joined: Wed Apr 05, 2017 1:57 am

Api studio + Delphi 10.1 Berlin

Tue Mar 13, 2018 1:44 am

Hello guys, I just donwload the studio api from the forum and try to compile but it says "decimalseparator" undeclared!!!!

Any atual version to run on Berlin?

Thanks
 
irawan
just joined
Posts: 5
Joined: Wed Mar 28, 2018 4:10 am

Re: Complete DELPHI API client: update 4

Tue Jul 31, 2018 4:37 am

This error is not come from RouterOSAPI.
Look at this link https://stackoverflow.com/questions/315 ... rsion-of-s and some adjustment yourself.
I have no newer Delphi here, so can not help you more than this.
 
jwilkinson6028
just joined
Posts: 8
Joined: Wed Feb 10, 2016 9:21 pm

Re: Complete DELPHI API client: update 4

Mon Jul 08, 2019 11:36 pm

I can no longer login via API after updating to the latest 6.45.1
I would like to have this fixed as I want to use newer features of RouterOS and still use this API.
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8305
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Complete DELPHI API client: update 4

Tue Jul 30, 2019 2:02 pm

rodolfo, any plans on fixing it? ☝️
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.
 
hermeson
just joined
Posts: 16
Joined: Wed Apr 05, 2017 1:57 am

Re: Complete DELPHI API client: update 4

Tue Jul 30, 2019 6:13 pm

Master @Chupaka what is the difference of API and Radius? any vantage to set my APP with Radius logic or API would it do? As I can see the app around, when people use Radius all request are not listed on log list, on the other hand everything I do with API shows on log... any suggestion for that? Thanks

Who is online

Users browsing this forum: No registered users and 8 guests