Page 1 of 1

API Issue

Posted: Mon Jun 04, 2018 4:22 pm
by russell.it
Hey all,

I am having some issues with API's in our nagiosxi instance. I have added

Code: Select all

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule nagiosxi/api/v1/(.*)$ /usr/local/nagiosxi/html/api/v1/index.php?request=$1 [QSA,NC,L]
</IfModule>
To the ssl.conf file above the </VirtualHost>

Which fixed the first error I was getting (page not found) now I am getting a "NoEndpoint:" if I tail the httpd error log I get "Php Notice: Undefined inex: request in /usr/local/nagiosxi/html/api/v1/index.php on line 37"

Any ideas on where to look next?

I have tried a few of the example links from the "Help with Nagios XI" page. I have checked my user is a full admin and has api access enabled.

Re: API Issue

Posted: Tue Jun 05, 2018 9:06 am
by lmiltchev
What is the version of Nagios XI that you are currently using? You are not using a URL that goes through a proxy, are you?

Please show us the exact URL that you are using to get the API, minus the API key. Thank you!

Re: API Issue

Posted: Wed Jun 06, 2018 4:23 pm
by russell.it
https://nagios-server/nagiosxi/api/v1/s ... Z&pretty=1 the result of that url is "NoEndpoint:"

Currently running 5.4.13

No proxy

Re: API Issue

Posted: Thu Jun 07, 2018 9:32 am
by lmiltchev
This seems like an apache config issue. We need to do some more digging into it to be sure. Can you post the entire /etc/httpd/conf/httpd.conf, /etc/httpd/conf.d/nagiosxi.conf, and /etc/httpd/conf.d/ssl.conf files, so that we can review them?

Re: API Issue

Posted: Thu Jun 07, 2018 5:50 pm
by russell.it
Configuration files uploaded as requested. :)

Re: API Issue

Posted: Fri Jun 08, 2018 10:19 am
by lmiltchev
Remove the following lines from the nagiosxi.conf:

Code: Select all

RewriteCond %{SERVER_PORT} =80
RewriteRule ^(.*) https://%{HTTP_HOST}/nagiosxi [L,R]
save, exit, and restart apache:

Code: Select all

service httpd restart
Let us know if this fixed the issue. Thank you!

Re: API Issue

Posted: Mon Jun 11, 2018 4:31 pm
by russell.it
Still the exact same error.

Code: Select all

NoEndpoint:
Tested with a few of the REST API test url's found in the docs section of our nagiosxi install.

Re: API Issue

Posted: Tue Jun 12, 2018 1:27 pm
by cdienger
There's a typo in ssl.conf. Change:

RewriteRule nagiosxi/api/v1/(.*)$ /usr/local/nagiosxi/html/api/v1/index.php?request$1 [QSA,NC,L]

to:

RewriteRule nagiosxi/api/v1/(.*)$ /usr/local/nagiosxi/html/api/v1/index.php?request=$1 [QSA,NC,L]

Re: API Issue

Posted: Tue Jun 12, 2018 4:38 pm
by russell.it
That was it missing = sign.

Thanks heaps.

I have tested both get and post methods with no issues.

Happy for this topic to be locked.