Invoke-Webrequest host variable, Invalid URI: The hostname could not be parsed
The Invoke-WebRequest
cmdlet takes an -Uri
and a -Headers
parameter. Also you can simplify the URL:
[string]$subKey = "AAAAA-BBBBB-FFFFFF-EEEEEE-DDDDD"
[string]$method = "GET"
[string]$searchParam = "Type"
[string]$searchQuery = "QQ"
$uri= "https://api.test.com/api/assets/search?$searchParam=$searchQuery&PageSize=10&Page=1"
Invoke-WebRequest -Uri $uri -Headers @{Authorization ="SubKey $subKey"} -Method Get