add servicegroup to service when creating service via rest
Posted: Fri Nov 09, 2018 9:57 am
I'm using the python requests package to post url calls to nagiosxi to create services. I would like to add the service to an existing service group when I create it. I cant figure out the parameter I need to specify in order to add a service to a servicegroup. Is that something I should be able to do when creating the service?
example code is:
payload = {'host_name' : devname,
'service_description': 'cisco stack status',
'service_groups' : 'cisco stack status',
'use' : 'cisco_stack',
'force' : 1
}
r = requests.post('https://' + nagioshost + '/nagiosxi/api/v1/config/service?apikey=' + nagiosapikey + '&pretty=1
&applyconfig', data=payload, verify=verify)
I've tried:
'service_groups' : 'cisco stack status',
'service_group' : 'cisco stack status',
'servicegroup' : 'cisco stack status',
the service group does exist:
{
"@attributes": {
"id": "36183"
},
"instance_id": "1",
"servicegroup_name": "cisco stack status",
"is_active": "1",
"config_type": "1",
"alias": "cisco stack status"
},
example code is:
payload = {'host_name' : devname,
'service_description': 'cisco stack status',
'service_groups' : 'cisco stack status',
'use' : 'cisco_stack',
'force' : 1
}
r = requests.post('https://' + nagioshost + '/nagiosxi/api/v1/config/service?apikey=' + nagiosapikey + '&pretty=1
&applyconfig', data=payload, verify=verify)
I've tried:
'service_groups' : 'cisco stack status',
'service_group' : 'cisco stack status',
'servicegroup' : 'cisco stack status',
the service group does exist:
{
"@attributes": {
"id": "36183"
},
"instance_id": "1",
"servicegroup_name": "cisco stack status",
"is_active": "1",
"config_type": "1",
"alias": "cisco stack status"
},