REST API - Labels

Hi
I need to get and assign labels through REST API and powershell in Checkmk Enterprise 2.3.0p35.
But when I get labels I dont get all labels even through “REST API interactive GUI”

So is there difference in labels, have 2 differnt host with differnt labels, one I can get the labels:
image

the other server I have created a new host label and assigned though a Host label rule with start Patch, but I dont get any of the labels, not event the “cmk/”
image

I use this

But the labels is empty
image

What do I do wrong since I dont get all the labels?

The REST API endpoint you are using is for the configuration of a host. It will only be able to get and set labels that are directly set in the host properties. It will not show labels set by the agent (e.g. the ones starting with cmk/) and not the labels set by rules.

If you want to see all labels currently active on a host you need to use the API endpoint for the monitoring state of a host. The URL is {API_URL}/objects/host/{HOSTNAME}. For some reason it is not available in the Swagger web app.

Thanks
Got it to work once I understod I need to add columns.

I use PowerShell, so I can’t get multiple columns to work.

I do

$body = @{
            columns = 'labels'
}
Invoke-Restmethod -Uri $url -Method Get -Headers $headers -Body $body | ConvertTo-Json

But cannot get the format if I want more then labels, is that possible.