check if git branch is locked using api on azure devops

Viewed 469
2 Answers
https://{baseUrl}/{organisation}/{project}/_apis/git/repositories/{repoId}/refs?filter=heads/***/master&api-version=6.0
  • Replace the placeholders with correct details of your repos and give your branch name(heads/***/master) of which you want check it is locked or not.

enter image description here

  • One catch over here, if your branch is not locked then "Islocked" & "Creator" section will not ever get in response.

  • To get for all the branches info you can run url without filters eg. https://{baseUrl}/{organisation}/{project}/_apis/git/repositories/{repoId}/refs?&api-version=6.0

You are using the right Rest API.

GET https://{instance}/{collection}/{project}/_apis/git/repositories/{repositoryId}/refs?filter=heads/xxx &api-version=5.0 

Kindly check your URI Parameters just make sure you are using the right filter.

There should be isLocked and isLockedBy info of returned json file.

Related