Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

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

Bezawada Ashok November 7, 2023

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

1 vote
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.
November 8, 2023

Hi @Bezawada Ashok 

Instead of username try using uuid e.g.: users: [{"uuid": "{xxx}"}]

Bezawada Ashok November 8, 2023 edited

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.
November 9, 2023 edited

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

Bezawada Ashok November 9, 2023

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.
November 9, 2023

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

Bezawada Ashok November 9, 2023

@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.
November 9, 2023

Fantastic! 

Have a look here

Like Sabine Mayer likes this
0 votes
Bezawada Ashok November 9, 2023

Thanks @Saxea _Flowie_ 
That helped!!

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Product Admin
TAGS
atlassian, jira cloud certification, managing jira projects, jira project administration, jira cloud exam, atlassian certification, agile project management, jira workflows, jira permissions, jira training, jira cloud skills, atlassian learning

Become a Certified Jira Service Project Expert 🦸🏻‍♂️

Validate your expertise in managing Jira Service Projects for Cloud. Master configuration, optimize workflows, and manage users seamlessly. Earn global 🗺️ recognition and advance your career as a trusted Jira Service management expert.

Get Certified! ✍️
AUG Leaders

Atlassian Community Events