add servicegroup to service when creating service via rest

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
lukesullivan
Posts: 34
Joined: Tue Jan 24, 2017 11:12 am

add servicegroup to service when creating service via rest

Post by lukesullivan »

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"
},
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: add servicegroup to service when creating service via re

Post by ssax »

It's servicegroups, you can use the object definitions page to look them up:

https://assets.nagios.com/downloads/nag ... ml#service
Locked