Hello Thomas Murnane,
To get the commit ID, use the /annotatedtags endpoint with the tag’s objectId. below is simple PowerShell script to do it:
$organization = "your-org"
$project = "your-project"
$repositoryId = "your-repo-id"
$pat = "your-personal-access-token"
$headers = @{ Authorization = "Basic " + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(":$pat")) }
# Get the tags
$tagsUrl = "https://dev.azure.com/$organization/$project/_apis/git/repositories/$repositoryId/refs?filter=tags/&api-version=7.1-preview.1"
$tagsResponse = Invoke-RestMethod -Uri $tagsUrl -Method Get -Headers $headers
foreach ($tag in $tagsResponse.value) {
$tagName = $tag.name -replace "refs/tags/", ""
$tagObjectId = $tag.objectId
# Get the commit ID
$annotatedTagUrl = "https://dev.azure.com/$organization/$project/_apis/git/repositories/$repositoryId/annotatedtags/$tagObjectId?api-version=7.1-preview.1"
$annotatedTagResponse = Invoke-RestMethod -Uri $annotatedTagUrl -Method Get -Headers $headers
$commitId = $annotatedTagResponse.taggedObject.objectId
Write-Output "Tag: $tagName, Commit ID: $commitId"
}
This will give you the commit ID (like 418392bc for 24.2.1.601-RELEASE-CANDIDATE) that matches the UI.
Hope this helps!
If the answer is helpful, please click Accept Answer and kindly upvote it. If you have any further questions about this answer, please click Comment.