here a little working sample. Testet with 2.1.0p21:
import json
import requests
_api_url = f'https://your.cmk.host:443/your_site/check_mk/api/1.0'
_base_header = {
'Authorization': f'Bearer your_automation_user your_automation_secret',
'Accept': 'application/json',
'Content-Type': 'application/json',
}
url = f'{_api_url}/domain-types/host_config/collections/all'
data = {
'folder': '/subfolder1/subfolder2',
'host_name': 'your_new_host',
}
data = json.dumps(data)
response = requests.post(
url=url,
headers=_base_header,
data=data,
)