I am working on script where I want to find out name of folder where user committed changes
$AzureDevOpsPAT = ""
$OrganizationName = ""
$AzureDevOpsAuthenicationHeader = @{Authorization = 'Basic ' + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(":$($AzureDevOpsPAT)")) }
$UriOrga = "https://dev.azure.com/$($OrganizationName)/"
$uriAccount = $UriOrga + "{Project Name}/_apis/git/repositories/{RepositoryID}/items?api-version=6.0-preview.1"
Invoke-RestMethod -Uri $uriAccount -Method get -Headers $AzureDevOpsAuthenicationHeader -ContentType "application/json"
This is returning (It does return recent commit ID , Object ID but in path it returns only /)
path=/;
Also with
$uriAccount = $UriOrga + "{Project Name}/_apis/git/repositories/{REPO ID}/commits?api-version=6.0-preview.1"
It returns -
author=; committer=; (Nothing for these values just blank)
Que - Am I using wrong API call ? How can I get Folder name , Committer name ?
Thanks
We can get the commit Folder name via commit ID
GET https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/commits/{commitId}/changes?api-version=6.0-preview.1
Result:
And get the committer name via below API
Get https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/commits/{commitId}?api-version=6.0-preview.1
Result:
Update1
get the committer name
I used postman to track these results, and I also tried powershell script, please check it.
$url = "https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/commits/{commitId}?api-version=6.0-preview.1"
$connectionToken="PAT"
$base64AuthInfo= [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($connectionToken)"))
$CommitInfo = Invoke-RestMethod -Uri $url -Headers @{authorization = "Basic $base64AuthInfo"} -Method Get
Write-Host "CommitInfo = $($CommitInfo | ConvertTo-Json -Depth 100)"
Result: