I'm using PowerShell's Invoke-WebRequest applet to make a basic authenticated connection to the bitbucket REST API. I Want to get a json snippet file.
Error Message: Access Denied.
__________________________________________________________________________________
$bitBucketUsername = "Email"
$bitBucketPassword = "XXXX"
$pair = "$($bitBucketUsername):$($bitBucketPassword)"
$encodedCreds = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($pair))
$basicAuthValue = "Basic $encodedCreds"
$response2 =
Invoke-WebRequest
-Method Get
-Uri 'https://api.bitbucket.org/2.0/snippets/UserID/EncodedID/files/XX.JSON'
-Headers @{ 'Authorization' = $($basicAuthValue)}
_________________________________________________________________________________
I also tried generating a PSCredential Object but it's not working.
If a try to connect to the API via Postman using my $basicAuthValue as an Authorization Header seems to be working fine, so it make me guess that the issue is the connection with powershell and not how I'm generating my credentials.