Update: Well, I was running this in a Bash script, but I wanted to see what error code I was getting, and now I can see I am getting a 401 Unauthorized. I am using my username and I created Personal Access Token with admin access bitbucket, so I should be able to create a PR right? I can do this through the web UI on the same repo?
I am running a bash script to create a pull request on Bitbucket. I already am programmatically cloning the repo, editing a file, doing a git add/commit, now I just need to use CURL to make the PR. It seems the bitbucket API exposes a endpoint to do this using a POST request:
Creates a new pull request where the destination repository is this repository and the author is the authenticated user.
The minimum required fields to create a pull request are title and source, specified by a branch name.
curl https://api.bitbucket.org/2.0/repositories/my-username/my-repository/pullrequests \
-u my-username:my-password \
--request POST \
--header 'Content-Type: application/json' \
--data '{
"title": "My Title",
"source": {
"branch": {
"name": "staging"
}
}
}'
Here's how my repo looks on Bitbucket, I blocked out the real names, but the left format the same (the first name is the Project name, REACTOR2.0, while I believe the second name is the repository name, dat-repo):
I am trying many different variations, and am checking the remote bitbucket server for a new pull request, but I see nothing.
I'm certain my "title" and "branch" are correct. My only question is about the URL; I am inputting my username from bitbucket, if you go to "Manage Account" then "name", that is the field I'm using for the my-username part of the URL, and I'm adding the repository name for the my-repository part. However, I need to note that this is a repository on bitbucket nested inside a Project called "REACTOR2.0", so I wasn't sure if the project name needed to be specified in the URL somewhere.
Has anyone been successful with this API? I looked on google, but many questions were using the old 1.0 API and don't apply or people were doing GET request do simply get a list of pull requests....
