I am kind of stuck here, I am trying to make an http call with credentials and client token from PowerShell uing "GET" to an in-house web application (I did not create). I keep getting error 500 from the server.
This application requires Preemptive authentication. The first time I got this to work was in ReadyAPI when I selected the "Authenticate Pre-emptively" radio, the request worked.
This is the definition according to ReadyAPI that the radio button does
Pre-emptive auth – Specifies if ReadyAPI will wait until an authorization challenge is received to send the credentials. The parameter has the following options:
Use global preference – Use the settings defined in the HTTP Settings global preferences.
Authenticate pre-emptively – For this request only. Do not wait until an authorization challenge is received to send the credentials.
I have seen that in C# there is a preemptive auth setting however I haven't found any such equivalent for PowerShell.
Has anyone ever run into this issue before? Is there a way powershell can issue a pre-emptive authentication?
This is what I have, but this is just basic setup...
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $user, $pass))) $headers = New-Object "System.Collections.Generic.Dictionary[[String], String]]" $headers = @{} $headers.Add('Authorization',('Basic {0}' -f $base64AuthInfo)) $headers.Add('X-IBM-Client-ID', $clientId ) $uri = "https://myURI/development/authorization/token" $invoke = Invoke-RestMethod -Headers $headers -Method Post -Uri $uri