Having trouble using the approach provided here:
Deploy build artifacts to Bitbucket Downloads
Running a Windows 10 VM with PowerShell 7.4.2.
This is the script I have tested:
$url = "https://api.bitbucket.org/2.0/repositories/${$BITBUCKET_REPO_OWNER}/${$BITBUCKET_REPO_SLUG}/downloads"
$pair = "{0}:{1}" -f ($BITBUCKET_USERNAME, $BITBUCKET_APP_PASSWORD)
$bytes = [System.Text.Encoding]::ASCII.GetBytes($pair)
$token = [System.Convert]::ToBase64String($bytes)
$headers = @{ Authorization = "Basic {0}" -f ($token) Accept = "application/json" }
$bin_file_path = "C:\Users\user\Documents\#21 Build Products.zip"
$form = @{ files = Get-Item -Path $bin_file_path }
$result = Invoke-RestMethod -Uri $url -Method Post -Form $form -Headers $headers
The response says "This endpoint does not support token-based authentication".
I have tried to re-create in PowerShell the example approach shown that uses the curl command, but without success.
I found a similar question raised here and the reply seems to suggest that basic authentication should work:
This endpoint does not support token-based authentication | Default reviewers
I appreciate your help.
G'day, @James Andrew
Welcome to the community!
I am not an expert in PowerShell script, so I can't comment much, but I suspect you are using incorrect authorization; hence, it received your credentials as a token, which the endpoint does not support. So, as a start, review your script again and ensure it works locally and uses the correct authorization method.
That say, you mention that you've tried using curl but without success, can you let me know what was the error or issue you faced?
Regards,
Syahrul
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.