Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Stash API - Fork Repository

Sagar Ghuge March 21, 2015

I want to fork one repository using Stash API. I am not able to understand properly which API should I use to fork repository. Like in github I use post request : https://api.github.com/repos/repo_name/forks with credentials to fork any repository. How should I achieve in stash API ? 

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

2 votes
Answer accepted
Michael Heemskerk
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 27, 2015

You're on the right track, but you're not providing a body to the POST that you're sending. You can for a repository as follows (using curl as an example):

curl -X POST -u {username} -H "Content-Type: application/json" http://{stash-server}/rest/api/latest/projects/{project_key}/repos/{repo_slug} -d 
'{"name":"my-fork", "project": {"key": "TEST"}}'

where {project_key}/{repo_slug} is the repository you want to fork. The example above will create a fork in the project with project_key TEST and will use 'my-fork' as the name of the fork.

The name and project fields are optional. If not set, the name will be identical to the name of the repository that you're forking. If not set, the project will default to your personal project.

However, even if you don't specify the project and/or repository name, you still need to provide a valid JSON body, which at a minimum would be :

curl -X POST -u {username} -H "Content-Type: application/json" http://{stash-server}/rest/api/latest/projects/{project_key}/repos/{repo_slug} -d '{}'
Sagar Ghuge March 27, 2015

Thanks al lot.. It helped me a lot :)

0 votes
Sagar Ghuge March 24, 2015

I used this : requests.post("https://{url}/rest/api/1.0/projects/{project_key}/repos/{repo_name}", auth=("username", "password"), verify=False, headers={"Content-type":"application/json"}), But it return 500 status code with this output : '{"errors":[{"context":null,"message":"An error occurred while processing the request. Check the server logs for more information.","exceptionName":null}]}'

TAGS
AUG Leaders

Atlassian Community Events