Community discussions

MikroTik App
 
SergeS
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 67
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: 7053
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
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 67
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: 7053
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
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 67
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: 7053
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
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 67
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?
 
User avatar
NetVicious
Member Candidate
Member Candidate
Posts: 128
Joined: Fri Nov 13, 2009 3:30 pm
Location: Spain

Re: How to read file content using API?

Mon Jul 22, 2019 9:50 am

More than one year later and the bug it's there yet.

I'm tryting to get the result of the /export command and it seems it's affected by the same limitation of the API.

Who is online

Users browsing this forum: Google [Bot] and 46 guests