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

Why do I get a "malformed value" error when creating a branch permission with API v2.0 ? Edited

I've been trying to create a branch restriction rule using the API v2.0:

I'm using python, and this is what my params and request look like:

data = {
"branch_match_kind" : "glob",
"kind" : "require_approvals_to_merge",
"type" : "branchrestriction",
"pattern" : branch,
"value" : str(br_approvals),
"users" : [],
"groups" : []

r ='' + user + '/' + repo_slug + '/branch-restrictions', auth=HTTPBasicAuth(user, password), data=data)

It contemplates every mandatory field, including "value", which is why I don't understand why I keep getting the following error:

b'{"type": "error", "error": {"message": "malformed value"}}'

Can anyone shed some light on this?

3 answers

1 accepted

1 vote
Answer accepted

I just figured it out. 


r ='' + user + '/' + repo_slug + '/branch-restrictions', auth=HTTPBasicAuth(user, password), json=data)

Apparently, when you pass a dict through data, it converts everything to a string, while the API is expecting an int.

Also, make sure value is an int. Don't convert it to a string.

0 votes


Any lack if you change double-quote into single quote?



Hi Gonchik,

Thanks for replying!

That didn't work either



I'm having the same issue here.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Bitbucket

Atlassian supported Jenkins integration for Bitbucket Server

We’ve been building a plugin to integrate Bitbucket Server and Jenkins CI, and I’m excited to announce that our alpha is ready to download and install. It lets you seamlessly configure a Jenkins job ...

398 views 0 9
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