REST-API: Problem with service discovery

CMK version:

Checkmk Raw Edition 2.1.0

OS version:

Debian 10 and RockyLinux 8


I am trying to automate my hosts creation with the new REST API.
I copy paste the example that we can find on this link : Configuration via the Checkmk REST API
Everything works fine but when it comes to Service Discovery it didn’t work, I mean it doesn’t show me an error i have got a return code 200 but it did nothing.
I tried to do it with bash and python but the result is the same. Here an example of what i am trying to do:



  curl \
    --request POST \
    --write-out "\nxxx-status_code=%{http_code}\n" \
    --header "Authorization: Bearer $USERNAME $PASSWORD" \
    --header "Accept: application/json" \
    --header "Content-Type: application/json" \
    --data '{
          "mode": "refresh"
        }' \
echo $out
resp=$( echo "${out}" | grep -v "xxx-status_code" )
code=$( echo "${out}" | awk -F"=" '/^xxx-status_code/ {print $2}')

# For indentation, please install 'jq' (JSON query tool)
echo "$resp" | jq
# echo "$resp"

if [[ $code -lt 400 ]]; then
    echo "OK"
    exit 0
    echo "Request error"
    exit 1

Here the result :

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   371  100   332  100    39    410     48 --:--:-- --:--:-- --:--:--   458
{"links": [{"domainType": "link", "rel": "self", "href": "", "method": "GET", "type": "application/json"}], "domainType": "service_discovery", "id": "myhost-services-wato", "title": "Services discovery", "members": {}, "extensions": {}} xxx-status_code=200
  "links": [
      "domainType": "link",
      "rel": "self",
      "href": "",
      "method": "GET",
      "type": "application/json"
  "domainType": "service_discovery",
  "id": "myhost-services-wato",
  "title": "Services discovery",
  "members": {},
  "extensions": {}

I had to re-activate the legacy web API to do what i want but it is not a solution…
Thank you for your answer !


EDIT : with 2.0.X version it’s working not with 2.1.X version

1 Like

Hey, i have the same problem since i upgraded in 2.1.x but worked 2.0.x

Have you resolved this problem?