wget returns a 404 error when downloading a repo's archive from the Downloads page
Platform Notice: Cloud Only - This article only applies to Atlassian apps on the cloud platform.
Problem
You use a command like the following to download an archive of a Bitbucket Cloud repo from the Downloads page:
wget --user=<atlassian_account_email> --ask-password https://bitbucket.org/workspace-id/repo-slug/get/master.tar.gz where
<atlassian_account_email>: your Atlassian account email
workspace-id: the ID of the workspace where the repo belongs. For example, if your repo's URL is https://bitbucket.org/workspace-id/repo, then workspace-id is the ID of the workspace
repo-slug: the repo slug. For example, if your repo's URL is https://bitbucket.org/workspace-id/repo, then repo is the repo slug
master: this could be the name of a different branch or the commit hash of one of the repo's commits
Wget returns the following error:
--2023-12-15 15:14:36-- https://bitbucket.org/workspace-id/repo-slug/get/master.tar.gz
Resolving bitbucket.org (bitbucket.org)... 104.192.141.1
Connecting to bitbucket.org (bitbucket.org)|104.192.141.1|:443... connected.
HTTP request sent, awaiting response... 404 Not Found
2023-12-15 15:14:36 ERROR 404: Not Found.Cause
The wget command always waits for the 403 challenge from the server before it sends the credentials to the server. However, Bitbucket Cloud servers initially send a 404 status to the client, and as a result, wget doesn't send credentials later on.
Solution
First solution
Use the --auth-no-challenge flag in the wget command as follows:
wget --auth-no-challenge --user=<atlassian_account_email> --ask-password https://bitbucket.org/workspace-id/repo-slug/get/master.tar.gz When you get asked for a password, please ensure you are using an API token for your account, with at least the scope read:repository:bitbucket, and not your account's password.
Otherwise, you will get a 401 error because we have deprecated the use of Atlassian account passwords for Git and Bitbucket API activity.
Second solution
Use curl to download the repo archive:
curl --request GET --url 'https://bitbucket.org/workspace-id/repo-slug/get/master.zip' -u <atlassian_account_email>:<api_token> --output repo1.zipwhere <atlassian_account_email> is your Atlassian account email and <api_token> is an API token for that account with at least the scope read:repository:bitbucket.
Was this helpful?