Using PowerShell, invoke a GET from Autosys Web Server (AEWS) end point, the GET calls error out until a POST attempt is made against the same end point.
## below are default credentials ejmadmin:ejmadmin converted to base64.
$headers = @{
'Authorization' = 'Basic ZWptYWRtaW46ZWptYWRtaW4='
}
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}
## Very first GET call errors out
Invoke-RestMethod -Uri https://MyAutosysServer.example.com:9443/AEWS/job/test -Method GET -ContentType "application/json" -Headers $headers
Invoke-RestMethod : The underlying connection was closed: An unexpected error occurred on a send.
At line:1 char:1
+ Invoke-RestMethod -Uri https://MyAutosysServer.example.com:9443/AEWS/job/test -Met ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebExc
eption
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
## The above errors continue until you try a POST to the same URL.
Invoke-RestMethod -Uri https://MyAutosysServer.example.com:9443/AEWS/event/force-start-job -Method POST -Body '{"jobName":"test"}' -ContentType "application/json" -Headers $headers
## now the same GET call works fine
Invoke-RestMethod -Uri https://MyAutosysServer.example.com:9443/AEWS/job/test -Method GET -ContentType "application/json" -Headers $headers
name : test
jobType : CMD
machine : MyAutosysAgent
self : @{@href=https://MyAutosysServer.example.com:9443/AEWS/job/test; @rel=self}
status : 4
AutoSys Workload Automation
Microsoft Windows PowerShell
PowerShell appears to block the first GET call somehow and it does not seem to be a problem after performing a POST.
The above needs to be done for each REST end point per each PowerShell session.
It appears to be a problem with PowerShell as it stands today. The issue seems to happen with other REST end points too.
Alternative is to use curl to do these operations instead. Any opensource curl module on Windows is OK too.