[API] Possible to add multiple contacts when creating a service?
Posted: Mon May 20, 2024 1:07 pm
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?
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?