I am trying to restrict the permissions for a specific AD group on a branch level. Previously I have asked the Microsoft Azure DevOps team if they had any endpoint URI REST API for this request, but the response that I have got was that it was not currently available. However, I have managed to get the API using the chrome developer tool, which was
https://dev.azure.com/{organization}/_apis/accesscontrolentries/{namespacetoken}?api-version=5.1
Then, I am making the POST request using this body below,
branchPermissionbody = {
"token": "{}".format(permissionToken),
"merge": True,
"accessControlEntries": [
{
"descriptor": "Microsoft.TeamFoundation.Identity;{}".format(descriptorIdentifier),
"deny": 4,
"extendedinfo": {}
}
]
}
The Permission Token, is in the format of ,
repoV2/{projectID}/{repositoryID}/refs/heads/{branchID}/
and the descriptoridentier is something we can get.
Here, I am stuck on getting the branchID. For example, if the branch we are trying to restrict are master
, support%5E
, how do we grab these branch ID using the developer tool?
You can use this tool to convert your branch name to branch id automatically. https://onlineunicodetools.com/convert-unicode-to-hex
For a test, I get my master branch id from Developer tool, it is 6d0061007300740065007200
like below.
And then use this tool to convert master
to hex.
These values are same. Then what about support%5E
Hope this will help.