In order to do the trigger I am using the below powershell commands(Also I don't want to use the username password for auth, is there any other way to to that? may be using a PAT or something):
$url = "https://<host>/rest/api/latest/queue/<ProjectKey>-<BuildKey>"
$header = @{
"Content-Type"="application/json"
}
$body = @{
"Authorization"="Bearer <Key>"
} | ConvertTo-Json
Invoke-RestMethod -Uri ([Uri]$url) -Method Post -Headers $header -body $body
But I keep getting the below error:
Invoke-RestMethod : Unable to connect to the remote server..
What am I missing in the above line..or is there any other way to achieve this?