Are you in the loop? Keep up with the latest by making sure you're subscribed to Community Announcements. Just click Watch and select Articles.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Getting 500 Internal server error when trying to create a branch restriction using API

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"
}
}

2 answers

1 accepted

0 votes
Answer accepted
Saxea _Flowie_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Nov 08, 2023

Hi @Bezawada Ashok 

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"
}
}

Saxea _Flowie_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Nov 09, 2023 • edited

The uuid need to be around "{...}", so uuid: "{730581e7-aed6-4c75-b2cd-32f81cbb9a6d}"

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"
}
}

Saxea _Flowie_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Nov 09, 2023

It should be one POST for each entry, instead of sending an array for data.

@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?

Saxea _Flowie_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Nov 09, 2023

Fantastic! 

Have a look here

Like Sabine Mayer likes this

Thanks @Saxea _Flowie_ 
That helped!!

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events