PATCH request to lock branch of ADO repository failure

Viewed 70

I'm attempting to use the ADO api to lock repository branches, following the instructions provided here https://docs.microsoft.com/en-us/rest/api/azure/devops/git/refs/update-ref?view=azure-devops-rest-5.1&tabs=HTTP.

Command:

$curl -d '{"isLocked": true}' -H 'Content-Type: application/json' PATCH "https://dev.azure.com/{my_org}/{my_project}/_apis/git/repositories/{my_repo}/refs?filter=heads/{my_branch}&api-version=5.1"

response:

{"$id":"1","innerException":null,"message":"Value cannot be null.\r\nParameter name: refUpdates","typeName":"System.ArgumentNullException, mscorlib","typeKey":"ArgumentNullException","errorCode":0,"eventId":0

Can anyone provide any insight on what refUpdates parameter/value needs to be added to the request body to create a valid request?

1 Answers

The below works on my side:

curl --location --request PATCH 'https://dev.azure.com/<Organization>/<Project>/_apis/git/repositories/<Repo Name>/refs?filter=heads/<branch name>&api-version=5.1' \
--header 'Authorization: Basic <Personal Access Token>' \
--header 'Content-Type: application/json' \
--data-raw '{
    "newRefInfo": "",
    "IsLocked":true
}'

enter image description here

Adding newRefInfo seemed to be necessary.

Related