Downtime on multiple hosts via url or REST API

hello @LaSoe i have create the below powershell script and it works perfectly for 1 host: if i manually specify it (dxbesx1)
but if i uncomment the line 10 to get the content of a txt file each ost on seperate line, i got error that the bad request status 400 host_name not a valid string
below is the script:

#Put the Hosts in checkmk Downtime

#Disable SSL Verification
[System.Net.ServicePointmanager]::ServerCertificateValidationCallback = {$true}
$username = "api-user"
$secret = "apisecret"
####Get the list of hosts entered in the DTESXList.txt

#$hostlist = get-content -Path "C:\nca\PowerCLI PS\BOS Patches\DTESXList.txt"
#write-host $hostlist

$hostname = "dxbesx1"

#### Time Zone Variables
$Delta = 60
$StartTime = Get-Date
$EndTime = $StartTime.AddMinutes($Delta)
$StartTimeREST = [System.String]$(Get-Date $StartTime -Format 'yyyy-MM-ddTHH:mm:ssK')
$EndTimeREST = [System.String]$(Get-Date $EndTime -Format 'yyyy-MM-ddTHH:mm:ssK')




####Header Inputs
$Header = @{
"Authorization" = "Bearer $username $secret"
}

foreach ($hostname in $hostlist) {

###### Hashtable
##### the Z at the end is for UTC Time Zone
$Data = @{
   "start_time" = $startTimerest
   "end_time" = $endTimerest
   "recur" = "fixed"
   "comment" = "Security updates"
   "downtime_type" = "host"
   "host_name" = $hostname
} | ConvertTo-Json

$Parameters = @{
Method = "POST"
Uri = "https://checkmk.xx.com/ncamaster/check_mk/api/1.0/domain-types/downtime/collections/host"
Headers = $Header
Body = $data
ContentType = "application/json"
}

Invoke-RestMethod @Parameters


}

===================================

error:
Invoke-RestMethod @Parameters
}
Invoke-RestMethod : {"title": "Bad Request", "status": 400, "detail": "These fields have problems: host_name", "fields": {"host_name": ["Not a valid string."]}}
At line:51 char:1

can anyone advise please?