How do I add a reviewer when I create a pull request via the API?

Mark Wallis July 14, 2021

Looking at the documentation here. This should work:

{
    "title": "My Title",
    "source": {
        "branch": {
            "name": "my-feature-branch"
        }
    },
    "reviewers": [
        {
            "uuid": "{504c3b62-8120-4f0c-a7bc-87800b9d6f70}"
        }
    ]
}

But it does not, I get a 400.

If I remove the "reviewers" property from the json, the PR creates successfully.

I have confirmed the uuid that I am using is correct (via a call to {{baseUrl}}/workspaces/:ourworkspace/members) and has access to the repo.

So, I don't 'think' I'm doing anything wrong. Can you confirm the functionality works and the documentation is correct? And if so, any suggestions for what else to try?

This is my json:

{ "title": "my PR title",
"source": { "branch": { "name": "sourcebranch" } },
"destination": { "branch": { "name": "develop" } },
"reviewers": [ { "uuid": "{valid-uuid}" } ]

}

1 answer

0 votes
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 20, 2021

Hi Mark,

I can confirm that this works for me using an API call like the following:

curl -u <username>:<app-password> -X POST https://api.bitbucket.org/2.0/repositories/<workspace-id>/<repo-slug>/pullrequests -H "Content-Type: application/json" -d '{"title":"My Title","source":{"branch":{"name":"test3"}},"destination":{"branch":{"name":"master"}},"reviewers":[{"uuid":"{85h7ba24-d516-4fo6-980c-e5fa6829a41e}"}]}'

Could you try testing the API call with curl (in case you haven't already)?
If you get the same error, could you please copy-paste here the exact call and the full output, sanitizing any private/sensitive info like username, password, workspace-id etc?

Kind regards,
Theodora

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events