Page 1 of 1

use API to delete User account

Posted: Thu May 26, 2016 2:17 pm
by SteveBeauchemin
I am trying to use the API to delete a user from Nagios XI.
I can list the user by following the Nagios XI GUI help screen.

Code: Select all

curl -XGET "http://localhost/nagiosxi/api/v1/system/user?apikey=[key]&pretty=1"
and the data is listed

Code: Select all

        {
            "user_id": "9",
            "username": "blah",
            "name": "blah 2",
            "email": "blah 3 @ xxx.com",
            "enabled": "1"
        },
then, trying to delete

Code: Select all

curl -XDELETE "http://localhost/nagiosxi/api/v1/system/user?apikey=[key]&pretty=1&user_id=9"
returns this

Code: Select all

{
    "error": "User with ID  does not exist."
}
I am logged in to the host using ssh.
The API Key I am using is for the nagiosadmin account.
So, what am I doing wrong?

Thanks

Steve B

Re: use API to delete User account

Posted: Thu May 26, 2016 4:46 pm
by rkennedy
I was able to reproduce this, and it seems to be a bug. I've filed a report for it, ID #8634.

Code: Select all

MariaDB [nagiosxi]> SELECT * FROM xi_users WHERE user_id="2";
+---------+----------+----------------------------------+------+---------+------------------------------------------------------------------+---------+
| user_id | username | password                         | name | email   | backend_ticket                                                   | enabled |
+---------+----------+----------------------------------+------+---------+------------------------------------------------------------------+---------+
|       2 | bob      | 098f6bcd4621d373cade4e832627b4f6 | a    | [email protected] | 9ugftqso6phnnoshp9dk0um63khm584b4kp0cjnhc673t3ik9u87stcsgtik3ks5 |       1 |
+---------+----------+----------------------------------+------+---------+------------------------------------------------------------------+---------+
1 row in set (0.00 sec)

Code: Select all

You have new mail in /var/spool/mail/root
[root@localhost ~]# curl -XDELETE "http://192.168.4.179/nagiosxi/api/v1/system/user?apikey=uui5lt5s&pretty=1&user_id=2"
{
    "error": "User with ID  does not exist."
}

Re: use API to delete User account

Posted: Thu May 26, 2016 5:14 pm
by rkennedy
The developers got back to me, and this is going to be the proper syntax. (the help page is wrong)

Code: Select all

[root@localhost ~]# curl -XDELETE "http://192.168.4.179/nagiosxi/api/v1/system/user/2?apikey=uui5lt5s&pretty=1"
Success.Userremoved.
[root@localhost ~]#

Re: use API to delete User account

Posted: Fri May 27, 2016 9:56 am
by SteveBeauchemin
Thanks for the solution.

Much appreciated.

Feel free to close this item.

Steve B

Re: use API to delete User account

Posted: Mon May 30, 2016 7:23 am
by rkennedy
No problem!

Closing this one out.