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

Bitbucket Cloud API does not work with cURL or wget

Eric Molina-Martinez June 20, 2022

I'm trying to download an artifact I have uploaded to Bitbucket Downloads through cURL or wget. The issue seems to be that the cURL and wget don't receive an answer from the Bitbucket API.

How to reproduce:

- Have a file stored in https://bitbucket.org/${BITBUCKET_REPO_OWNER}/${BITBUCKET_REPO_SLUG}/downloads/

- Have an App password

- Use cURL/wget and the API to download the file.

- No output returns.

 

I have tried different variations, for example with a different Agent-Header:


curl -A "Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/81.0" -u ${USER} https://api.bitbucket.org/2.0/repositories/${BITBUCKET_REPO_OWNER}/${BITBUCKET_REPO_SLUG}/downloads/${file}

 

But does not work.

I also have tried to follow the Step3b from the Deploy build artifacts to Bitbucket Downloads

but instead of POST trying with GET but the output is:

curl: (26) Failed to open/read local data from file/application

 

I'm not sure if the issue is from my side or any kind of bug or problem with the Bitbucket Cloud API.

1 answer

1 accepted

1 vote
Answer accepted
Eric Molina-Martinez June 20, 2022

Fixed this.

The problem is related to the redirects. cURL was not following the redirects.

The -L flag makes cURL follow to the last redirect and downloads the file.

Example:

curl -L --compressed -X GET -u ${USER} https://api.bitbucket.org/2.0/repositories/${BITBUCKET_REPO_OWNER}/${BITBUCKET_REPO_SLUG}/downloads/${file} > ${file}.tgz

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events