Community discussions

MikroTik App
 
hasan2221
just joined
Topic Author
Posts: 18
Joined: Wed Mar 06, 2024 10:08 pm

api not giving any response

Wed Mar 06, 2024 10:11 pm

[admin@MikroTik] > /ip/service/print
Flags: X - DISABLED, I - INVALID
Columns: NAME, PORT, ADDRESS, CERTIFICATE, VRF
# NAME PORT ADDRESS CERTIFICATE VRF
0 X telnet 23 main
1 X ftp 21
2 www 80 172.16.0.0/24 main
3 X ssh 22 main
4 X www-ssl 443 none main
5 api 8728 0.0.0.0/0 main
6 winbox 9291 main
7 X api-ssl 8729 root-cert main
[admin@MikroTik] > /tool fetch http-method=get url=http://172.16.0.1:8728/rest/sys
tem/resource check-certificate=no user=admin password=""
status: failed

failure: Idle timeout - waiting data
 
User avatar
Amm0
Forum Guru
Forum Guru
Posts: 3509
Joined: Sun May 01, 2016 7:12 pm
Location: California

Re: api not giving any response

Thu Mar 07, 2024 12:53 am

5 api 8728 0.0.0.0/0 main

failure: Idle timeout - waiting data


Remove the "allowed access". It should be grey in winbox, so may need to hit the up arrow there to remove it. Otherwise, it matching if the caller's IP is 0.0.0.0 I suspect. Although I get 0.0.0.0/0 should be everything... I know it being unset means allowed everywhere for sure.
 
User avatar
Amm0
Forum Guru
Forum Guru
Posts: 3509
Joined: Sun May 01, 2016 7:12 pm
Location: California

Re: api not giving any response

Thu Mar 07, 2024 12:58 am

Opps. By "API", you mean the REST API. That's a different problem. When you use the CLI, the src-address is loopback 172.0.0.1. So that needs to be in the allowed-address for www in your case.

And, as REST is an HTTP-based API, the port for it is "80" NOT 8728.
/tool fetch url=http://172.16.0.1/rest/ip/address
[admin@MikroTik] > /ip/service/print
2 www 80 172.16.0.0/24 main

[admin@MikroTik] > /tool fetch http-method=get url=http://172.16.0.1:8728/rest/sys
tem/resource check-certificate=no user=admin password=""
status: failed

failure: Idle timeout - waiting data
Last edited by Amm0 on Thu Mar 07, 2024 1:20 am, edited 3 times in total.
 
mszru
Frequent Visitor
Frequent Visitor
Posts: 79
Joined: Wed Aug 10, 2016 10:42 am

Re: api not giving any response

Thu Mar 07, 2024 1:17 am

And remove the port 8728 from the url...
 
User avatar
Amm0
Forum Guru
Forum Guru
Posts: 3509
Joined: Sun May 01, 2016 7:12 pm
Location: California

Re: api not giving any response

Thu Mar 07, 2024 1:33 am

And remove the port 8728 from the url...
LOL. I have the edit window open but didn't hit save.

Better url to output to screen. output=user will cause it print to console to see results.
/tool fetch url=http://172.16.0.1/rest/ip/address output=user
 
hasan2221
just joined
Topic Author
Posts: 18
Joined: Wed Mar 06, 2024 10:08 pm

Re: [SOLVED] api not giving any response

Thu Mar 07, 2024 8:41 am

And remove the port 8728 from the url...
LOL. I have the edit window open but didn't hit save.

Better url to output to screen. output=user will cause it print to console to see results.
/tool fetch url=http://172.16.0.1/rest/ip/address output=user
Thanks actually the doc said www but i totally ignored it bcz the winbox states api service. it worked. How can i edit the title to solved?
 
mszru
Frequent Visitor
Frequent Visitor
Posts: 79
Joined: Wed Aug 10, 2016 10:42 am

Re: api not giving any response

Thu Mar 07, 2024 11:18 am

How can i edit the title to solved?
Find the reply that helped solve the problem and use the checkbox on the very right side of the reply header. Alternatively you can mark your own reply where you stated that the problem has been resolved.

Who is online

Users browsing this forum: Alek1234, broderick, gigabyte091, Google [Bot] and 19 guests