Created
January 26, 2018 22:06
-
-
Save molekilla/debd4d0a058cb33eed24816b0c28fa2b to your computer and use it in GitHub Desktop.
Requests a REST API with Basic Authentication
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Call REST API | |
$SecurePassword = Get-Content httpbin_creds.txt | ConvertTo-SecureString -Key (1..16) | |
$Username = "johnlopez" | |
$cred = New-Object System.Management.Automation.PSCredential ($Username, $SecurePassword) | |
Invoke-RestMethod -Uri "http://httpbin.org/basic-auth/$Username/password123456789" ` | |
-Method Get -Credential $cred -ContentType "application/json" -Body $json |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment