REST API how to add/delete hosts to/from a host group

Thanks for you suggestion, but this does not work. I’m a little lost on this. What am I doing wrong?

I tried both:

  json={
        'ruleset': 'host_label_rules',
        'folder': '/folder/subfolder',
        'properties': {
            'disabled': False
        },
        'value_raw': "\"{'MyHostGroup'}\"",
        'conditions': {}
  }

and:

  json={
        'ruleset': 'host_label_rules',
        'folder': '/folder/subfolder',
        'properties': {
            'disabled': False
        },
        'value_raw': "\"{'Assignment of hosts to host groups': 'MyHostGroup'}\"",
        'conditions': {}
  }

Throws:

raise RuntimeError(pprint.pformat(resp.json()))
RuntimeError: {‘detail’: ‘These fields have problems: ruleset_name’,
‘fields’: {‘ruleset_name’: [‘Missing data for required field.’]},
‘status’: 400,
‘title’: ‘Bad Request’

Thanks
Martin

1 Like