atlassian-python-api icon indicating copy to clipboard operation
atlassian-python-api copied to clipboard

Bitbucket API does not allow the fork of the repository

Open Kevin-Palmerini opened this issue 2 years ago • 1 comments

Dear all, I've faced some issues while trying to fork a repository from a project. I've tried both the functions, that are: def fork_repository(self, project_key, repository_slug, new_repository_slug) and def fork_repository_new_project(self, project_key, repository_slug, new_project_key, new_repository_slug). So for my bitbucket object, i've initializated it as follows: BITBUCKET = Bitbucket(url="https://api.bitbucket.org/", username=USERNAME, password=PASSWORD) but when I call the two functions above, I got this error: Traceback (most recent call last): File "bitbucketcloud_createFork.py", line 170, in <module> test_fork_repository_in_different_project(workspace_ID, project_KEY, repository_NAME, new_project_KEY, new_repository_NAME) File "bitbucketcloud_createFork.py", line 137, in test_fork_repository_in_different_project data = BITBUCKET.fork_repository_new_project(project_KEY, repository_NAME, new_project_KEY, new_repository_NAME) File "C:\Users\Kevin Palmerini\anaconda3\lib\site-packages\atlassian\bitbucket\__init__.py", line 885, in fork_repository_new_project return self.post(url, data=body) File "C:\Users\Kevin Palmerini\anaconda3\lib\site-packages\atlassian\rest_client.py", line 320, in post response = self.request( File "C:\Users\Kevin Palmerini\anaconda3\lib\site-packages\atlassian\rest_client.py", line 247, in request self.raise_for_status(response) File "C:\Users\Kevin Palmerini\anaconda3\lib\site-packages\atlassian\rest_client.py", line 412, in raise_for_status raise HTTPError(error_msg, response=response) requests.exceptions.HTTPError

Can someone help me to understand what happens? The USERNAME and PASSWORD are correct because if I change them without changing the rest of code, I got the credentials error.

Kevin-Palmerini avatar Jun 09 '22 07:06 Kevin-Palmerini

I've noticed that the URL passed through the POST method for the forking of the repository was incorrect: /2.0/projects/<project-key>/repos/<repos-slug>/ The correct one should be: </2.0/repositories/<workspace>/<repos-slug>/forks> So I've added one more function inside '../atlassian/bitbucket/init.py'

Kevin-Palmerini avatar Jun 09 '22 09:06 Kevin-Palmerini