REST api and recursive folders

CMK version:
check-mk-raw-2.2.0p12
and
check-mk-managed-2.1.0p26

OS version:
Debian GNU/Linux 12 (bookworm)

Error message:
n/a

I’ve started writing against the rest api and want to collect all tags from one or more host(s). I pulled the info using

$API_URL/objects/host_config/home-ap101

and got an (correct) answer. One thing listed in it is

       {
            "domainType": "link",
            "href": "http://<myhost>/<mysite>/check_mk/api/1.0/objects/folder_config/~network~wifi",
            "method": "GET",
            "rel": "urn:com.checkmk:rels/folder_config",
            "title": "The folder config of the host.",
            "type": "application/json"
        }

Which is correct. The AP is located in the folder “network/wifi” Then I pulled the info from the folder

http://1<myhost>/<mysite>/check_mk/api/1.0/objects/folder_config/~network~wifi

And combined the tags from the two. Now I am still missing a lot of tags, since most are set on the folder ‘network’ which is parent to ‘wifi’
Should I not have received a link to that parent folder from the second api call ??
Or am i expected to dissect the folder path and collect the info from each parent folder that way?

Regards,
Anton

I think you overwrite the folder attributes by running this API call. If you use this method, you should use attributes, update_attributes or remove_attributes for your needs.

Rg, Christian

1 Like

Thanks,
I tried the request

"{API_URL}/domain-types/host_config/collections/all", params={ "effective_attributes": True, },

but still only receive the tags set on the device, not the parent folders. But maybe I should first go to a newer release in by test environment …

same on
OMD - Open Monitoring Distribution Version 2.2.0p20.cre

Copy/paste once more from ReDoc example and … Somehow it’s now working.

resp = session.get(
  f"{API_URL}/domain-types/host_config/collections/all",
    params={ 
        "effective_attributes": True,
    },
)

(or I might have missed that attributes are spread over two different keys in the answer
‘attributes’ and ’ effective_attributes’. Not sure, but I migth)