Missing REST API endpoints?

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
speterson
Posts: 3
Joined: Thu Jan 05, 2017 11:15 am

Missing REST API endpoints?

Post 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?
Last edited by dwhitfield on Mon Jan 09, 2017 11:13 am, edited 1 time in total.
Reason: marking with green check mark
bwallace
Posts: 1145
Joined: Tue Nov 17, 2015 1:57 pm

Re: Missing REST API endpoints?

Post 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"
Be sure to check out the Knowledgebase for helpful articles and solutions!
speterson
Posts: 3
Joined: Thu Jan 05, 2017 11:15 am

Re: Missing REST API endpoints?

Post 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'.
jomann
Development Lead
Posts: 611
Joined: Mon Apr 22, 2013 10:06 am
Location: Nagios Enterprises

Re: Missing REST API endpoints?

Post 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>
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
speterson
Posts: 3
Joined: Thu Jan 05, 2017 11:15 am

Re: Missing REST API endpoints?

Post 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!
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: Missing REST API endpoints?

Post 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!
Locked