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

Stash PR REST API for User Repositories

Daniel Sobral July 22, 2013

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
Michael Heemskerk
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 22, 2013

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:

http://example.com/rest/api/1.0/projects/~johnsmith/repos

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

http://example.com/rest/api/1.0/users/~{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:

http://example.com/rest/api/1.0/projects/~johnsmith/repos/nodejs/forks

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

http://example.com/rest/api/1.0/users/johnsmith/repos/nodejs/forks
sergio neira December 10, 2013

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

Thanks

seb
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 10, 2013

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

https://developer.atlassian.com/static/rest/stash/latest/stash-rest.html#idp2060848

0 votes
sergio neira December 10, 2013

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.

Sergio

seb
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 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.

https://bitbucket.org/atlassian/stash-command-line-tools/src/master/lib/atlassian/stash/pullrequest.rb?at=master

0 votes
sergio neira December 10, 2013

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" } } ] }

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events