Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

BitBucket API Post MERGED pull-request

Sharon Bamani
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 22, 2018

Is there a way to POST MERGED pull-request?

 

This is what I tried, but it didn't work:

This is my curl command:

curl -H 'Authorization: Bearer ************' -H "Content-Type: application/json" -X POST https://stash.sd.comp.com/rest/api/1.0/projects/MYPROJ/repos/MergeTest/pull-requests -d @./MigrateFiles/MergeTest/361807.json

 

This is the json file:

{
"title": "one more dream",
"description": "(created by ABA) ",
"state": "MERGED",
"open": false,
"closed": true,
"fromRef": {
"id": "refs/heads/mergedpull",
"repository": {
"slug": "MergeTest",
"name": null,
"project": {
"key": "MYPROJ"
}
}
},
"toRef": {
"id": "refs/heads/master",
"repository": {
"slug": "MergeTest",
"name": null,
"project": {
"key": "MYPROJ"
}
}
},
"reviewers": [
{
"user": {
"name": "sbamani"
}
}
]
}




It does creates the pull-request but it creates it OPEN:
{"id":14,"version":0,"title":"one more dream","description":"(created by ABA)","state":"OPEN","open":true,"closed":false,


Thanks,
Sharon

 

 

1 answer

1 accepted

2 votes
Answer accepted
Rodrigo M
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 23, 2018

Hey Sharon!

 

The concept of creating a Pull Request is to be able to perform a review of the code. So it's not possible to create and merge at the same time a PR.

 

You can create a PR and merge it by REST API's on separate steps. The endpoints to perform these actions are the below:

  1. create a PR
  2. Merge a PR

 

Regards

Rodrigo - Atlassian Support

Sharon Bamani
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 29, 2018

The need came because we were migrating from gitlab and we wanted to keep the PR info.

Is there a better way to do it? 

Rodrigo M
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 30, 2018

Hello Sharon

In order to move repositories, you will need to follow the steps in the Importing code from an existing project documentation.

This will keep your commit history, but not things such as comments. We still have an open feature request for this BSERV-4586.

You may also want to check out the following Atlassian Answers posts for more details. Some customers have designed scripts to automate this:

* https://answers.atlassian.com/questions/273025/gitlab-to-stash-migration
* https://answers.atlassian.com/questions/274693/looking-for-answers-on-migration-from-gitlab-to-stash

Regards
Rodrigo

Suresh Sakhare
Contributor
August 30, 2018

@Rodrigo M: Thanks above info. API documentation must include this information. API doc making an airhead. 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events