When I try to add branch-restriction for desired repo based on this documentation - https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/branch-restrictions with propper users or groups
data = {
"kind": "restrict_merges",
"pattern": "master",
"value": None,
"branch_match_kind": "glob",
"users": ["andrew_polishchuk"]
}
r = requests.post(url="https://api.bitbucket.org/2.0/repositories/%s/%s/branch-restrictions" % (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?
Did anyone else find an answer to this question?
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 = requests.post(url="https://api.bitbucket.org/2.0/repositories/%s/%s/branch-restrictions" % (org, repo), headers=headers, data=json.dumps(data))
Hopefully that helps others.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Andrew,
Did you ever figure out the answer to your question? I'm trying the same thing and having a hard time too.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.