API Issue

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
russell.it
Posts: 23
Joined: Sun Oct 26, 2014 7:46 pm

API Issue

Post 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.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: API Issue

Post 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!
Be sure to check out our Knowledgebase for helpful articles and solutions!
russell.it
Posts: 23
Joined: Sun Oct 26, 2014 7:46 pm

Re: API Issue

Post 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
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: API Issue

Post 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?
Be sure to check out our Knowledgebase for helpful articles and solutions!
russell.it
Posts: 23
Joined: Sun Oct 26, 2014 7:46 pm

Re: API Issue

Post by russell.it »

Configuration files uploaded as requested. :)
You do not have the required permissions to view the files attached to this post.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: API Issue

Post 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!
Be sure to check out our Knowledgebase for helpful articles and solutions!
russell.it
Posts: 23
Joined: Sun Oct 26, 2014 7:46 pm

Re: API Issue

Post 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.
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: API Issue

Post 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]
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
russell.it
Posts: 23
Joined: Sun Oct 26, 2014 7:46 pm

Re: API Issue

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