use API to delete User account

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
SteveBeauchemin
Posts: 524
Joined: Mon Oct 14, 2013 7:19 pm

use API to delete User account

Post 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
XI 5.7.3 / Core 4.4.6 / NagVis 1.9.8 / LiveStatus 1.5.0p11 / RRDCached 1.7.0 / Redis 3.2.8 /
SNMPTT / Gearman 0.33-7 / Mod_Gearman 3.0.7 / NLS 2.0.8 / NNA 2.3.1 /
NSClient 0.5.0 / NRPE Solaris 3.2.1 Linux 3.2.1 HPUX 3.2.1
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: use API to delete User account

Post 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."
}
Former Nagios Employee
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: use API to delete User account

Post 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 ~]#
Former Nagios Employee
SteveBeauchemin
Posts: 524
Joined: Mon Oct 14, 2013 7:19 pm

Re: use API to delete User account

Post by SteveBeauchemin »

Thanks for the solution.

Much appreciated.

Feel free to close this item.

Steve B
XI 5.7.3 / Core 4.4.6 / NagVis 1.9.8 / LiveStatus 1.5.0p11 / RRDCached 1.7.0 / Redis 3.2.8 /
SNMPTT / Gearman 0.33-7 / Mod_Gearman 3.0.7 / NLS 2.0.8 / NNA 2.3.1 /
NSClient 0.5.0 / NRPE Solaris 3.2.1 Linux 3.2.1 HPUX 3.2.1
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: use API to delete User account

Post by rkennedy »

No problem!

Closing this one out.
Former Nagios Employee
Locked