It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Adding reviewers to pull requests via REST API Edited

Konstantin Mizev Jan 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?

1 answer

1 accepted

1 vote
Answer accepted
Anna Li-Fatou Atlassian Team Jan 23, 2018

Hi Konstantin!

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!

Konstantin Mizev Jan 23, 2018

It's exactly what I need, thanx!

Steve Muskiewicz Apr 17, 2018 • edited

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
Rajvanth Reddy Kota I'm New Here 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"
}

]

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Bitbucket Pipelines

Building a Bitbucket Pipe as a casual coder

...ipe.sh :  #!/bin/bash source "$(dirname "$0")/common.sh" enable_debug extra_args="" if [[ "${DEBUG}" == "true" ]]; then extra_args="--verbose" fi # mandatory variables R...

3,374 views 3 22
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you