Community discussions

 
SergeS
just joined
Topic Author
Posts: 11
Joined: Fri Mar 25, 2016 6:23 am

How to read file content using API?

Fri Jul 13, 2018 12:43 am

I have some application, running Mikrotik API commands to export configuration to the .rsc file and save it as a file on the computer.
I have all steps done, valid .rsc file is created, but i cannot get file content to the computer. It is strange, because i have remembered this specific command was working around two years ago.
I was using command:
/file/print
=.proplist=contents
?name=filename.rsc
Command
/file/print
=from=%s.rsc
=detail=
is also not working...

How to get file content using API?
I see many people asking the same question but i did not see working suggestion...
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 5689
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: How to read file content using API?

Fri Jul 13, 2018 12:28 pm

You will not get file content if file size is larger than 4KB.
 
SergeS
just joined
Topic Author
Posts: 11
Joined: Fri Mar 25, 2016 6:23 am

Re: How to read file content using API?

Fri Jul 13, 2018 6:02 pm

You will not get file content if file size is larger than 4KB.
But it was definitely working for larger files, i have tried with export file (.rsc)...

Ok, how can I get file content if size is smaller than 4KB?
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 5689
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: How to read file content using API?

Fri Jul 13, 2018 6:34 pm

<<< /file/get
<<< =.id=*D034A
<<< =.proplist=contents
<<<
 
SergeS
just joined
Topic Author
Posts: 11
Joined: Fri Mar 25, 2016 6:23 am

Re: How to read file content using API?

Fri Jul 13, 2018 10:54 pm

/file/get
=.id=*D034A
=.proplist=contents
Ok, this one is working (for small files), thank you.
The way how i did it before:
/file/print
=.proplist=contents
?name=filename.ext
is also working (only for small files).

Still question is how to get >4Kb file content, using API?
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 5689
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: How to read file content using API?

Mon Jul 16, 2018 11:40 am

You can't directly with api. Download file via ftp and then read content locally.
 
SergeS
just joined
Topic Author
Posts: 11
Joined: Fri Mar 25, 2016 6:23 am

Re: How to read file content using API?

Mon Jul 16, 2018 6:18 pm

You can't directly with api. Download file via ftp and then read content locally.
Bad.. :-(.

Is this bug? or feature? It was working with some older versions of firmware. Are there any hope it may work in future versions?

Who is online

Users browsing this forum: No registered users and 5 guests