Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

HOWTO - Get past Bitbucket error from PowerShell GET call.

Please help us get past a Bitbuckt error.
We are trying to use PowerShell to get individual files from our Bitbucket repository with the following script:

$username = "MyId@MyPlace.com"
$password = "MyPwd"
$csSource = "https://bitbucket.org/MyCompany/MyRepo/SomeSubFolder/SoDeeperSubFolder/MyFile.html"
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $username,$password)))
$response = Invoke-RestMethod -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)} -Uri $csSource -Method Get

When we run this, we get this error:


Invoke-RestMethod : The request was aborted: Could not create SSL/TLS secure channel.
At line:1 char:13
+ $response = Invoke-RestMethod -Headers @{Authorization=("Basic {0}" - ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebExc
eption
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand


We have also tried this variation:


$username = "MyId@MyPlace.com"
$password = "MyPwd"
$csSource = "https://bitbucket.org/MyCompany/MyRepo/SomeSubFolder/SoDeeperSubFolder"
$credential = New-Object System.Management.Automation.PSCredential($username, (ConvertTo-SecureString $password -AsPlainText -Force))
$destination = "C:\MyFolder\MySubFolder\MyFile.CHK.html"
$response = Invoke-WebRequest $csSource -Credential $credential -OutFile (Join-Path -Path $destination -ChildPath "MyFile.html")

And we get the same error.

1 answer

I added the following logic and it gets past the error:

 

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

 

I'm very disappointed that no one helped with this.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Atlassian Community Events

Hello from city #68 on the road!

Hello from my sixty-eighth city in a long-term RV trip I started in 2015!  I've traveled all over the US staying in different cities and states for just a few days up to many months. This week I...

40 views 1 7
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you