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

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,456,379
Community Members
 
Community Events
176
Community Groups

I am not able to put the Branch restrictions using REST APIs.

Edited

I am trying to put the following permission using REST APIs

Screenshot from 2018-08-21 18-34-59.png

With the following JSON

$ json="[
{
"type": "read-only",
"matcher": {
"id": "refs/heads/master",
"displayId": "master",
"type": {
"id": "master",
"name": "master"
},
"active": true
},
"users": [
"admin"
],
"groups": []
}
]"

 

With the following Request:

$ curl -D- -u admin:admin -H "Content-Type: application/json" -X POST -d "$json" -X POST http://localhost:7990/rest/branch-permissions/2.0/projects/SAM/repos/branchPermissionTest/restrictions

 

Getting the following response with an error message 

 

HTTP/1.1 400 
X-AREQUESTID: @WUFJSOx924x697x0
X-ASEN: SEN-L12102830
X-AUSERID: 1
X-AUSERNAME: admin
Cache-Control: no-cache, no-transform
Vary: X-AUSERNAME,Accept-Encoding
Transfer-Encoding: chunked
Content-Type: application/json;charset=UTF-8
X-Content-Type-Options: nosniff
Date: Wed, 22 Aug 2018 09:54:30 GMT
Connection: close

{"errors":[{"context":null,"message":"Can not deserialize instance of com.atlassian.stash.internal.repository.ref.restriction.rest.RestRestrictionRequest out of START_ARRAY token\n at [Source: com.atlassian.stash.internal.web.util.web.CountingServletInputStream@ce51d28; line: 1, column: 1]","exceptionName":"org.codehaus.jackson.map.JsonMappingException"}]}

------------------------------------------------------------------------------------------------- 

Not sure what is going wrong here.

Need the guidance to form the correct JSON data for the above branch permission and also need suggestions if I am doing anything wrong with the request/parameters/anything else.

 

Thanks

 

 

2 answers

Adding header

-H "Content-Type: application/vnd.atl.bitbucket.bulk+json"

helped me.

Please, can anyone suggest what should be the JSON to prevent all changes on master/dev/release branches except admin? just like shown below in the screenshot.

awaiting for response.

Screenshot from 2018-08-21 18-34-59.png

 

Thanks

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events