The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

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

Create pull request via API: destination repository cannot be changed?

joel
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!
February 22, 2021

Hello,

I'm trying to create a PR via the API, where the source is my own fork, the the destination is the main repository. 

I get this error:

{"type": "error", "error": {"fields": {"destination": ["destination repository cannot be changed"]}, "message": "destination: destination repository cannot be changed"}}

 Here's my command:

curl \    
-X POST \
  -H "Content-Type: application/json" \
  -u username:app_password\
    https://bitbucket.org/api/2.0/repositories/username/repo-fork/pullrequests \
  -d '{      
"title": "test",
      
"description": "testing automated PR",
      
"source": {
        
"branch": {
          
"name": "test"
        
},
        
"repository": {
          
"full_name": "username/repo-fork"
        
}
      
},
      
"destination": {
        
"branch": {
         
  "name": "master"
        
},
        
"repository": {
          
"full_name": "username2/repo"
        
}
       
},
       
"reviewers": [ { "username": "user" } ],
       
"close_source_branch": false
    
}'

Why does this editor remove all my newline breaks when I paste code from my editor? Anyway... any ideas how do I make a PR from a fork to the main repository?

Thank you! 

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

0 votes
Answer accepted
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 22, 2021

Hi @joel ,

When you create a PR from a fork to the main repo, this PR is created in the main repo (and the fork is specified in the source).

Therefore, the API URL in the call should be the one of the main repo. I believe the issue with your call is that the URL of the fork is used and then you attempt to change the destination repo in the data.

You can change the URL and omit the "repository" part in the destination, like this:

curl \ 
-X POST \
-H "Content-Type: application/json" \
-u username:app_password\
https://bitbucket.org/api/2.0/repositories/username2/repo/pullrequests \
-d '{
"title": "test",
"description": "testing automated PR",
"source": {
"branch": {
"name": "test"
},
"repository": {
"full_name": "username/repo-fork"
}
},
"destination": {
"branch": {
"name": "master"
}
},
"reviewers": [ { "username": "user" } ],
"close_source_branch": false
}'

Is this something that works for you?

Kind regards,
Theodora

joel
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!
February 22, 2021

Yes it works, thank you!

Like Theodora Boudale likes this
TAGS
AUG Leaders

Atlassian Community Events