From the below API curl request, I am trying to create a restriction for push and restrict merges for a repository
curl --location 'https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_name}/branch-restrictions' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '[ {
"kind": "push",
"branch_match_kind": "glob",
"pattern": "test",
"users": [{"username": "{username}"}]
},
{
"kind": "restrict_merges",
"branch_match_kind": "glob",
"pattern": "test" ,
"users": [{"username": "{username}"}]
}]'
And I am getting the below error
{
"type": "error",
"error": {
"message": "Something went wrong",
"id": "674e26aa0b7b4227b3d7bea36d4bfc9c"
}
}
Instead of username try using uuid e.g.: users: [{"uuid": "{xxx}"}]
Hi @Saxea _Flowie_
I tried using uuid too instead of usernames. Still i get the same error
curl --location 'https://api.bitbucket.org/2.0/repositories/zestmoney/ashok_sandbox/branch-restrictions' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '[
{
"kind": "push",
"branch_match_kind": "glob",
"pattern": "test",
"users": [
{
"uuid": "730581e7-aed6-4c75-b2cd-32f81cbb9a6d"
}
]
},
{
"kind": "restrict_merges",
"branch_match_kind": "glob",
"pattern": "test",
"users": [
{
"uuid": "730581e7-aed6-4c75-b2cd-32f81cbb9a6d"
}
]
}
]'
Error:
{
"type": "error",
"error": {
"message": "Something went wrong",
"id": "6d61caada38d4ab7922a00068e8bf583"
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The uuid need to be around "{...}", so uuid: "{730581e7-aed6-4c75-b2cd-32f81cbb9a6d}"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Still i am getting the same error even after making that change
curl --location 'https://api.bitbucket.org/2.0/repositories/zestmoney/ashok_sandbox/branch-restrictions' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '[
{
"kind": "push",
"branch_match_kind": "glob",
"pattern": "test",
"users": [
{
"uuid": "{730581e7-aed6-4c75-b2cd-32f81cb9a6d}"
}
]
},
{
"kind": "restrict_merges",
"branch_match_kind": "glob",
"pattern": "test",
"users": [
{
"uuid": "{730581e7-aed6-4c75-b2cd-32f81cb9a6d}"
}
]
}
]'
Error:
{
"type": "error",
"error": {
"message": "Something went wrong",
"id": "7f89a4159a064e8eb8c2b7ef43d5cdb7"
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It should be one POST for each entry, instead of sending an array for data.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Saxea _Flowie_
Yes, it is working if i hit each entry in a separate POST request.
Also, is there any API which I can use for adding default reviewers to a repository?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Fantastic!
Have a look here
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.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.