0

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.

/REST/API/1.0/PROJECTS/{PROJECTKEY}/REPOS/{REPOSITORYSLUG}/ARCHIVE?AT&FILENAME&FORMAT&PATH&PREFIX

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'

headers = {'Content-Type': 'application/json'}

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

print(r.status_code)

404

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

Regards,

Kailash

1 Answers1

0

Bitbucket Server introduced the API you're talking about in Bitbucket 5.1.0. Prior to that, there was an unsupported Atlassian Labs plugin called the Stash Archive plugin, which provided similar functionality - however it had a slightly different API.

If you're using a version of Bitbucket earlier than 5.1.0, and you already have the above add-on installed, then you can use this very similar REST endpoint:

https://<bitbucket-base-url>/rest/archive/1.0/projects/<projectKey>/repos/<repoSlug>/archive?AT=xyz&filename=xyz.tar.gz&format=.tar.gz

If you don't have the above add-on installed, you can either install it or upgrade Bitbucket to 5.1.0 or higher (5.10.0 is the newest release at the time of writing).

See https://jira.atlassian.com/browse/BSERV-2732 for more background on all of the above.

daveruinseverything
  • 4,775
  • 28
  • 40