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 = 'https://bitbucket.xxxx.com/rest/api/1.0/projects/CMPOC/repos/hello-world/archive?at=b34bb40f9e5&format=zip'
>>> r = requests.get(url, auth=('username', 'password'), headers=headers)
I am getting 404 status code. Any help would be highly appreciated.
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 https://bitbucket.xxxx.com/login or https://bitbucket.xxxx.com/<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.
Dev Tools Support Engineer
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!
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.
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.
Dev Tools Support Engineer
I just reinstalled Bitbucket server archive plugin and now both the below url started working as expected with path= query
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 ...
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!
Unfortunately there are no AUG chapters near you at the moment.Start an AUG
We're bringing product updates and pro tips on teamwork to ten cities around the world.Save your spot