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 ?
Community moderators have prevented the ability to post new answers.
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 '{}'
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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}]}'
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.