Bitbucket Rest Api call using python resulting in 404 status code for archive


I am trying to use Bitbucket server rest api in python to get an archive of a certain commit. I am following the rest api documentation as below.


My python code to implement above api is as below.

>>> url = ''
>>> r = requests.get(url, auth=('username', 'password'), headers=headers)
>>> print(r.status_code)


I am getting 404 status code. Any help would be highly appreciated.



1 answer

0 votes

Hello Kailash,


I wrote a quick script in python3 to try the same and could only get a 404 if I put in the URL incorrectly (I also tried using the short hash and the full hash for the commit, it worked regardless of which I used). From what I can see, the actual rest call seems to be formulated correctly. So this can only be either the project, repo, or the base URL aren't added correctly. When you access your site (let's say on the login screen) do you see or<SOME CONTEXT PATH>/login? If it's the latter, ensure you place that in the API call as well as you need the context path for it to work.

If you aren't using a context path, I would try to navigate to the commit itself and confirm everything has been typed correctly.

Aaron Levinson
Dev Tools Support Engineer

Hi Aaron,

Thanks for your reply. I am able to get a 200 status code using below URL."

But I am not sure where its downloading the zip package or its downloading at all. Documentation only says it stream an archive but how can I save the archive to my local?

Appreciate your help!


Kailash Patra

Hi Aaron,"

Above URL was working till yesterday. If I add path= query to above URL it was downloading the content of the path only.

But today above url not working anymore. After doing some research seems like above url not valid anymore and below is the new url.

Also path= query is no longer working with this new url and its downloading the entire repo.

Appreciate if you could help.



Hello Kailash,


I'm unsure as to how a REST API would be valid one day, and not the next. The API doesn't change. You mentioned "path= query is no longer working." If you can show me exactly what query you are attempting to run and what you are expecting out of it, I can have a better chance of being able to assist you.


Aaron Levinson
Dev Tools Support Engineer

Suggest an answer

Log in or Join to answer
Community showcase
Piotr Plewa
Published Dec 27, 2017 in Bitbucket

Recipe: Deploying AWS Lambda functions with Bitbucket Pipelines

Bitbucket Pipelines helps me manage and automate a number of serverless deployments to AWS Lambda and this is how I do it. I'm building Node.js Lambda functions using node-lambda&nbsp...

638 views 0 4
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot