Forums

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

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

anoop maurya August 21, 2018

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

0 votes
Сергей Белесев
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 30, 2022

Adding header

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

helped me.

0 votes
anoop maurya August 23, 2018

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
AUG Leaders

Atlassian Community Events