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!
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.