[API] Possible to add multiple contacts when creating a service?

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Post Reply
ibdv
Posts: 2
Joined: Mon May 20, 2024 1:02 pm

[API] Possible to add multiple contacts when creating a service?

Post by ibdv »

Hello,

I couldn't find an answer for this, but it seems that when creating a service (or updating one via put) the contact is only set as the last value given in a list. The following code creates the service:

body = {
"host_name": "edge",
"service_description": "PEERING_123",
"check_command": "bgp_edge_check!edge01!edge02!!!!1!100!snmp",
"max_check_attempts": "3",
"check_period": "24x7",
"check_interval": "3",
"retry_interval": 3,
"notification_period": "24x7",
"notification_interval": "60",
"contacts": ["slack_support", "support"],
}
requests.post(url="https://10.0.0.50/nagiosxi/api/v1/config/service/", data=body, params=params, verify=False)


But it only has one contact "support" when I open it in the GUI. Is it possible to set multiple contacts via the API?
User avatar
jmichaelson
Posts: 383
Joined: Wed Aug 23, 2023 1:02 pm

Re: [API] Possible to add multiple contacts when creating a service?

Post by jmichaelson »

The API reference documentation at /nagiosxi/help/ uses query parameters as its examples. While it doesn't document how to go about adding multiple contacts to a host in this way, I'd try using some of the examples from /nagiosxi/help/api-common-solutions.php as guides, and using something like &contacts[]=slack_support&contacts[]=support.
Please let us know if you have any other questions or concerns.

-Jason
snapier3
Posts: 144
Joined: Tue Apr 23, 2019 7:12 pm

Re: [API] Possible to add multiple contacts when creating a service?

Post by snapier3 »

I do this a ton in Python...

Modify your list format
"contacts": ["slack_support", "support"],
Change to this and see what you get ;)

Code: Select all

"contacts": ["slack_support, support"],
--SN
ibdv
Posts: 2
Joined: Mon May 20, 2024 1:02 pm

Re: [API] Possible to add multiple contacts when creating a service?

Post by ibdv »

snapier3 wrote: Mon May 20, 2024 2:56 pm I do this a ton in Python...

Modify your list format
"contacts": ["slack_support", "support"],
Change to this and see what you get ;)

Code: Select all

"contacts": ["slack_support, support"],
--SN
Oh my word, this did the trick it looks like. Thank you!
Post Reply