Stash PR REST API for User Repositories

I'm trying to figure out what would be the syntax to create a pull request through the REST API. The description of the POST request is rather lacking, but, assuming one sends something similar to what GET retrieves, I'm still left with one problem: how do I specify the reference to a repository that is not on a project, but, rather, on a user?

3 answers

1 accepted

0 votes
Answer accepted

As described under 'Personal Repositories' in the Stash REST API documentation:

Stash allows users to manage their own repositories, called personal repositories. These are repositories associated with the user and to which they always have REPO_ADMIN permission.

Accessing personal repositories via REST is achieved through the normal project-centric REST URLs using the user's slug prefixed by tilde as the project key. E.g. to list personal repositories for a user with slug "johnsmith" you would make a GET to:

In addition to this, Stash allows access to these repositories through an alternate set of user-centric REST URLs beginning with:{userSlug}/repos

E.g. to list the forks of the repository with slug "nodejs" in the personal project of user with slug "johnsmith" using the regular REST URL you would make a GET to:

Using the alternate URL, you would make a GET to:

Michael, so, we can only READ data using REST API? what about if i want to creat a new pull request using REST API?


Seb Ruiz Atlassian Team Dec 10, 2013

@sergio - you can create pull requests using the rest api, please read the docs:

forget it, i found the way to call it, i was not seeying the request description in the top.

{ "title": "Talking Nerdy", "description": "It’s a kludge, but put the tuple from the database in the cache.", "state": "OPEN", "open": true, "closed": false, "fromRef": { "id": "refs/heads/feature-ABC-123", "repository": { "slug": "my-repo", "name": null, "project": { "key": "PRJ" } } }, "toRef": { "id": "refs/heads/master", "repository": { "slug": "my-repo", "name": null, "project": { "key": "PRJ" } } }, "reviewers": [ { "user": { "name": "charlie" } } ] }

Thanks for the answer @Seb Ruiz

i have readed this doc all day and also searched in google, but im not sure how to create the REST call of that API method.

reading the stash rest help (link you provided) i can see that call to is to get the pull requests of a branch, because in the params i cant see the necessary params to create a pull request:

[Source branch], [Destination branch], [Description], [reviewers]...etc.

can you maybe provide me a link or an example of a valid REST call to create the pull request with the params?

i really apreciate any help.

Thanks a lot again.


Seb Ruiz Atlassian Team Dec 10, 2013

POST creates a pull request, GET retrieves the pull requests. You need to add a post body with details.

You can look at the stash command line tool which does this with Ruby.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Thursday in Bitbucket Pipelines

Building a Bitbucket Pipe as a casual coder :  #!/bin/bash source "$(dirname "$0")/" enable_debug extra_args="" if [[ "${DEBUG}" == "true" ]]; then extra_args="--verbose" fi # mandatory variables ROLLBAR_ACCESS_TOKEN...

159 views 0 11
Read article

Atlassian User Groups

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!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you