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

This widget could not be displayed.

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

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 Ruiz Atlassian Team Dec 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

This widget could not be displayed.

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" } } ] }
This widget could not be displayed.

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 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.

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

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Aug 21, 2018 in Bitbucket

Branch Management with Bitbucket

As a project manager, I have discovered that different developers want to bring their previous branching method with them when they join the team. Some developers are used to performing individual wo...

1,595 views 9 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