Page 1 of 1

Missing REST API endpoints?

Posted: Thu Jan 05, 2017 12:25 pm
by speterson
I currently have NagiosXI 5.3.0 installed on a CentOS 6.7 server. I've been looking to use the REST API, however, every time I try to GET anything, I get a 404 returned. Looking at the error logs, I see "File does not exist: /usr/local/nagiosxi/html/api/v1/system". Going to the /usr/local/nagiosxi/html/api/v1 directory, the only thing it contains is "index.php". After doing a search on my server, there are no other locations that contain the system, objects, or config endpoints.

What am I missing and how can I resolve this issue?

Re: Missing REST API endpoints?

Posted: Thu Jan 05, 2017 2:02 pm
by bwallace
Could you post the full curl request you use?
By any chance did you install Nagios XI in custom location other than the default of /usr/local ?

Does the basic 'get host status' command work? Such as:
curl -XGET "http(s)://x.x.x.x/nagiosxi/api/v1/objects/hoststatus?apikey=cbg02sl7&pretty=1"

Re: Missing REST API endpoints?

Posted: Thu Jan 05, 2017 5:15 pm
by speterson
NagiosXI is installed in /usr/local/.

curl -XGET "http://<myhost>/nagiosxi/api/v1/objects/hoststatus?apikey=<mykey>&pretty=1" gets the following response:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /nagiosxi/api/v1/objects/hoststatus was not found on this server.</p>
<hr>
<address>Apache/2.2.15 (CentOS) Server at nagiosxi.accessdevelopment.com Port 80</address>
</body></html>


I get this response for anything under system and config too.

From /var/log/httpd/error_log:
[Thu Jan 05 15:07:51 2017] [error] [client xxx.xxx.xxx.xxx] File does not exist: /usr/local/nagiosxi/html/api/v1/objects
[Thu Jan 05 15:08:40 2017] [error] [client xxx.xxx.xxx.xxx] File does not exist: /usr/local/nagiosxi/html/api/v1/objects


The directory '/usr/local/nagiosxi/html/api/v1' only has one file in it, 'index.php'.

Re: Missing REST API endpoints?

Posted: Thu Jan 05, 2017 6:02 pm
by jomann
Did you do any editing of the nagiosxi.conf in the apache configuration? We add the following that should allow the index.php to manage all requests sent to the API:

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>

Re: Missing REST API endpoints?

Posted: Mon Jan 09, 2017 11:06 am
by speterson
It looks like the nagiosxi.conf file was changed in support of implementing SSL. Thankfully the original file was renamed to .old and I was able to use it as a context for updating the new file. Long story short, I'm able to get responses from the REST API now. Thanks for the assistance!

Re: Missing REST API endpoints?

Posted: Mon Jan 09, 2017 11:13 am
by dwhitfield
Glad to hear it is resolved. I am going to lock the thread. Please feel free to post again if you have you another issue. Thank you for using the Nagios forums!