BUG: RestAPI ERROR 403 Powershell

Hallo wir versuchen grad per API+ Powershell ein Service Discovery anzustoßen.
CheckMK 2.1.0.P38
Company daten mit xxx ersetzt:

> [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
> Invoke-WebRequest -Uri https:/xxxx
> $HOST_NAME= "xxx”
> $SITE_NAME= “xxx”
> #$API_URL= “https://$HOST_NAME/$SITE_NAME/check_mk/api/1.0/domain-types/host_config/collections/all”
> #$API_URL2= "https://$HOST_NAME/$SITE_NAME/check_mk/api/1.0/domain-types/activation_run/actions/activate-changes/invoke"
> 
> $API_URL3= "https://$HOST_NAME/$SITE_NAME/check_mk/api/1.0/domain-types/service_discovery_run/actions/start/invoke"
> 
> $USERNAME= "xxx"
> $PASSWORD= "xxx" 
> 
> $Headers = @{
> ‘Accept’ = ‘application/json’
> ‘Authorization’ = "Bearer $USERNAME $PASSWORD"
> 
> 
> }
> $BODY3='{"host_name": "schrott44", "mode": "refresh"}'
> 
> Invoke-RestMethod -Method Post -Uri $API_URL3 -Headers $Headers -Body $BODY3 -ContentType "application/json"

Result:

Invoke-RestMethod -Method Post -Uri $API_URL3 -Headers $Headers -Body …
     |  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | {"title": "Unexpected status code returned: 403", "status": 500, "detail": "Endpoint cmk.gui.plugins.openapi.endpoints.service_discovery.execute_service_discovery\nThis is a bug, please report.", "ext": {"codes": [302, 409, 200, 400, 415,
     | 400]}}

Ist ein “Automation User” mit den rechten lt. Doku.
Hosts anlegen + löschen geht ohne Probleme.

Hat da jemand eine Idee dazu ?

Es kann sein, dass sich die Methode für den Aufruf geändert hat. In 2.2 z.B. heißt der Aufruf:

$API_URL/domain-types/discovery_run/actions/bulk-discovery-start/invoke"

Hast du es mal mit der Interaktiven GUI probiert?

Danke für den Tip.
Pfad lt. Doku (Redoc 2.1)

“$API_URL/domain-types/service_discovery_run/actions/start/invoke”)

"title": "Unexpected status code returned: 403", "status": 500, "detail": "Endpoint cmk.gui.plugins.openapi.endpoints.service_discovery.execute_service_discovery\nThis is a bug, please report.", "ext": {"codes": [302, 409, 200, 400, 415,
     | 400]}}

Ok. Meldung ist ja auch “BUG”.

In der GUI klappt es natürlich :slight_smile:

mit dem “Bulk-Discovery” klappt es auch.

Gruß
Claus