Forums

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

Adding reviewers to pull requests via REST API

almostcake
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!
January 23, 2018

Hola!
I've discovered API documentation, but still suffer with finding the way to add or delete reviewers from existing pull request. As I've understood, the endpoint I need is PUT /2.0/repositories/{username}/{repo_slug}/pullrequests/{pull_request_id} , 
but I am getting 500 errors like "This QueryDict instance is immutable" or 400 with

"title": [
"This field is required."
]

Could someone please provide CURL snippet or even better POSTMAN one?

4 answers

2 accepted

4 votes
Answer accepted
Caterina Curti
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 4, 2023

Have a look at this article I just published about this:

Add a reviewer to a PR using the REST API and Forge 

 

It contains a link to a fully functional Forge app to add reviewers to a PR (here is the link if you want to check that out directly: Assign PRs randomly to a specific list of users in Bitbucket Cloud ).

 

Cheers,
Caterina

Benjamin Fichtner March 4, 2025

What is the reason that the default reviewers or users specified in a Codeowners file of a repository are not automatically added to Pull requests that are created via API? 

Suhas Sundararaju
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 11, 2025

Hi Benjamin,

Currently codeowners only works via the UI. The reason is when we go to the PR Create screen, it calls the codeowners handler to get what we are suggested to add to the PR. The API does not call this code to get those reviewers.

We kindly request you to watch and follow the feature request below for updates:

🔗 BCLOUD-23663 – Enable Bitbucket Pull Request API to Auto-Add Reviewers Based on CODEOWNERS

 

1 vote
Answer accepted
Anna
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 23, 2018

Hi!

You are using the correct endpoint to update reviewers. Title is required, so make sure you send that along and also if you do use curl, make sure to send the content type of json. 

I will gladly provide you the curl command that you need to be able to add and/or delete reviewers from an existing PR using our API. 

Steps:

You will need the uuid for the user(s), which you can get by calling this endpoint.

1. Save your request payload to a file:

printf '{ "title": "README.md edited online with Bitbucket", "reviewers": [{ "uuid": "{replace_me_with_an_actual_uuid}"}]}' > payload

2. Call the endpoint to update your reviewers:

curl -X PUT -u 'username:password' https://api.bitbucket.org/2.0/repositories/{owner}/{repo_slug}/pullrequests/{pullrequest_id} -d @payload --header "Content-Type: application/json" -v

You were likely getting the immutable error due to missing the content type.

Let us know if you have any further difficulty!

almostcake
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!
January 23, 2018

It's exactly what I need, thanx!

Steve Muskiewicz
Contributor
April 17, 2018

FYI I found that if you have the Bitbucket username, you can also pass it {"username": "<username>"} directly without having to go lookup the UUID first

Like Alex Xie likes this
Deleted user May 26, 2019

@Steve Muskiewicz Tried this: Does not work. Gives me a Malformed reviewers list. 

Is there something wrong with syntax ? 

"reviewers": [
{
"username":"user1"
}

]

Nick Hammond
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!
July 4, 2019

@[deleted] username was deprecated as part of Atlassian's privacy changes. see https://developer.atlassian.com/cloud/bitbucket/bitbucket-api-changes-gdpr/#removal-of-usernames-from-user-referencing-apis

tcorbu
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 18, 2021
1 vote
Lee, Keonjae
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!
March 4, 2020

 I want to add the repository's default reviews as reviews. What should I do in this case ?

0 votes
Caterina Curti
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 21, 2023

Edit: I wrote an app to do that. Check it out in the Add a reviewer to a PR using the REST API and Forge article.

 

Since the answer above has been written a few things changed in the payload format for updating the PR reviewers:

- the title is not required anymore

- the reviewers can be specified with the following JSON:

{ "reviewers": [ 
{ "account_id" : "<Atlassian Account ID>" }
]}

 

 

Make sure that the reviewer has permission to access the repository, otherwise a generic error will be returned stating:

{ "type":"error",
"error":
{ "message": "reviewers: Malformed reviewers list",
"fields":{"reviewers":["Malformed reviewers list"]}
}
}

 This can be resolved by granting the user access to the repository.

 

The specified reviewer can't be the author of the pull request (meaning the user who created the pull request). When that's the case, the request fails with the following error:

{ "type":"error",
"error":
{ "message": "reviewers: CCurti is the author and cannot be included as a reviewer.",
"fields": {"reviewers":["CCurti is the author and cannot be included as a reviewer."]}
}
}

 

Caterina

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events