Trying to enable service checks via api

CMK version: CEE 2.1.0p2
OS version: Appliance

Error message:
{“title”: “An exception occurred.”, “status”: 500, “detail”: “Failed to get host from folder ‘’.”}

When using the api to add hosts, do a service discovery and then enable service checks, I get an error I don’t understand. (The documentation implies that the POST to discover_services should be enough to add the discovered services, but I can’t find any trace in the CheckMK source that actually adds the services)
First I POST {"mode'": "new"} to /objects/host/hostname-of-server/actions/discover_services/invoke
In the reply I get that I should PUT for example {"check_type": "mounts","service_item": "/","target_phase": "monitored"} to /objects/host/hostname-of-server/actions/update_discovery_phase/invoke`
But I only get the error message back.