Hello,
I’m using CFE 2.0.0p11 and would like to create hosts with custom tags using the REST API but it is failing. Here is my request and response where “tag_host_type” is the custom tag. Note that the built-in tag “tag_address_family” is fine:
curl -X 'POST' \
'http://192.168.50.2/site/check_mk/api/1.0/domain-types/host_config/collections/all' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"folder": "/core",
"host_name": "tc001",
"attributes": {
"ipaddress": "192.168.50.1",
"tag_address_family": "ip-v4-only",
"tag_host_type": "test_client"
}
}'
{
"title": "Internal Server Error",
"status": 500,
"detail": "'NoneType' object has no attribute 'get'",
"crash_id": "e615ac6a-4ba4-11ec-aabe-fa163e5c0a06",
"crash_report": {
"href": "http://10.20.161.190/site/check_mk/crash.py?crash_id=e615ac6a-4ba4-11ec-aabe-fa163e5c0a06&site=site",
"method": "get",
"rel": "cmk/crash-report",
"type": "text/html"
},
"stack_trace": [
"Traceback (most recent call last):",
" File \"/omd/sites/site/lib/python3/cmk/gui/wsgi/applications/rest_api.py\", line 403, in _wsgi_app",
" return wsgi_app(environ, start_response)",
" File \"/omd/sites/site/lib/python3/cmk/gui/wsgi/applications/rest_api.py\", line 207, in __call__",
" wsgi_app = self.func(ParameterDict(path_args))",
" File \"/omd/sites/site/lib/python3/cmk/gui/plugins/openapi/restful_objects/decorators.py\", line 533, in _validating_wrapper",
" response = self.func(param)",
" File \"/omd/sites/site/lib/python3/cmk/gui/plugins/openapi/endpoints/host_config.py\", line 79, in create_host",
" body['folder'].create_hosts([(host_name, body['attributes'], None)])",
" File \"/omd/sites/site/lib/python3/cmk/gui/watolib/hosts_and_folders.py\", line 1867, in create_hosts",
" self.verify_host_details(host_name, attributes)",
" File \"/omd/sites/site/lib/python3/cmk/gui/watolib/hosts_and_folders.py\", line 1890, in verify_host_details",
" _must_be_in_contactgroups(_get_cgconf_from_attributes(attributes)[\"groups\"])",
" File \"/omd/sites/site/lib/python3/cmk/gui/watolib/hosts_and_folders.py\", line 2134, in _get_cgconf_from_attributes",
" v = attributes.get(\"contactgroups\", (False, []))",
"AttributeError: 'NoneType' object has no attribute 'get'",
""
]
}
Am I doing something wrong here or could it be a bug?
Thanks!