What is the equivalent of
curl -u username:password ...
in PowerShell's Invoke-RestMethod
? I tried this:
$securePwd = ConvertTo-SecureString "password" -AsPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential ($username, $securePwd)
Invoke-RestMethod -Credential $credential ...
but it returns 401, Unauthorized.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…