API returns wrong status code on failure

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
sib
Posts: 111
Joined: Thu Dec 11, 2014 8:06 am

API returns wrong status code on failure

Post by sib »

Hi

The API does not return the correct HTTP Status codes on failure. This returns HTTP 200 even though there is an error

Version: 5.6.2

Code: Select all

}, 
    "json": {
        "error": "Missing required variables", 
        "missing": [
            "host_name", 
            "service_description", 
            "max_check_attempts", 
            "check_interval", 
            "retry_interval", 
            "check_period", 
            "notification_interval", 
            "notification_period", 
            "contacts OR contact_groups"
        ]
    }, 
    "msg": "OK (230 bytes)",
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: API returns wrong status code on failure

Post by npolovenko »

Hello, @sib. The HTTP 200 OK status means that the HTTP request has been processed successfully. While the error below indicates that Nagios will not be able to add the service because some required fields were missing. But this is a separate logic. From the HTTP standpoint, the request went through successfully.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
sib
Posts: 111
Joined: Thu Dec 11, 2014 8:06 am

Re: API returns wrong status code on failure

Post by sib »

Hi

I still think this is missleading. It should be a 4xx i.e Bad Request error if the request has missing mandatory fields.
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: API returns wrong status code on failure

Post by npolovenko »

@sib, I understand. I'm going to submit a feature request on your behalf to add this functionality.
Please keep in mind that the decision to implement the enhancement is at the discretion of our development team.
Let me know if you have any other API related concerns.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
sib
Posts: 111
Joined: Thu Dec 11, 2014 8:06 am

Re: API returns wrong status code on failure

Post by sib »

Hi

No other questions. Thanks for the RFE
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: API returns wrong status code on failure

Post by npolovenko »

@sib, No problem. Closing this thread as resolved.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Locked