I had a Powershell script that used Invoke-RestMethod that was working in powershell 3.0. However, I upgraded to powershell 4.0 to fix a bug in powershell 3. When I did so, my script seems to have stopped working.
$username = "Administrator"
$password = "PASSWORD"
$uri = "https://10.0.0.18/vmrest/users"
$dictionary = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f$username,$password)))
$dictionary.Add("Authorization",$base64AuthInfo)
Invoke-RestMethod -Uri $uri -Method GET -Headers $dictionary -Verbose
When I turn on the verbose switch, it gives me this response
VERBOSE: GET https://192.168.1.18/vmrest/users with 0-byte payload
VERBOSE: received -1-byte response of content type
I also tried specifying the requested content type, but no dice
$dictionary.Add("Accept","application/json")
$dictionary.Add("Connection", "keep_alive")