Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Butbucket REST API v2 users and groups format for POST

Andrew Polischuk April 22, 2020

When I try to add branch-restriction for desired repo based on this documentation - with propper users or groups 

data = { 
"kind": "restrict_merges",
"pattern": "master",
"value": None,
"branch_match_kind": "glob",
"users": ["andrew_polishchuk"]

r ="" % (org, repo), headers=headers, data=data)
return r.json()

it returns

{"type": "error", "error": {"message": "malformed users"}} 

If users is a list of dictionaries (as mentioned in docs) with "nickname", "username" or both it still returns the same error json, i.e. with this 

"users": [
"username": "andrew_polishchuk"

Is there any valid payload for adding the desired branch-restriction based on users or groups?

3 answers

0 votes
Edwin Chung February 10, 2024

Did anyone else find an answer to this question?

0 votes
reuben.j September 4, 2023

Hi Andrew, 


In case this is still an issue, or could help others. We ran into the same issue recently and after some digging, found the issue to be an error in the data formatting when passing it into the request. 


For example, try using json.dumps(data), like this: 

r ="" % (org, repo), headers=headers, data=json.dumps(data)) 


Hopefully that helps others. 

0 votes
abhin October 20, 2020

Hi Andrew,

Did you ever figure out the answer to your question? I'm trying the same thing and having a hard time too.

Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events