This API call somehow returns TF401175: The version descriptor <Branch: refs/heads/.....> could not be resolved to a version in the repository ...
, even though the branches both definitely exist and I do have the necessary access
I dont know why, but this code looks correct to me. I also tried refs/heads/{sourceBranch}
and refs/heads/{targetBranch}
, that didnt work either
Can someone help?
public async Task<GitCommitRef[]> GetCommits(string sourceBranch, string targetBranch)
{
VssConnection conn = new(new Uri(this._azureDevOpsUrl), new VssBasicCredential(string.Empty, pat));
GitHttpClient client = conn.GetClient<GitHttpClient>();
List<GitCommitRef> commits = [];
try
{
List<GitCommitRef> res = await client.GetCommitsAsync(projectname, reponame, new GitQueryCommitsCriteria
{
ItemVersion = new GitVersionDescriptor
{
// I also tried refs/heads/{sourceBranch} and refs/heads/{targetBranch}, didnt work either
VersionType = GitVersionType.Branch,
Version = sourceBranch
},
CompareVersion = new GitVersionDescriptor
{
VersionType = GitVersionType.Branch,
Version = targetBranch
}
});
if (res != null)
{
commits.AddRange(res);
}
}
catch (Exception ex)
{
ConsoleEx.Throw($"Error fetching commits: {ex.Message}");
}
return commits.ToArray();
}
This API call somehow returns TF401175: The version descriptor <Branch: refs/heads/.....> could not be resolved to a version in the repository ...
, even though the branches both definitely exist and I do have the necessary access
I dont know why, but this code looks correct to me. I also tried refs/heads/{sourceBranch}
and refs/heads/{targetBranch}
, that didnt work either
Can someone help?
public async Task<GitCommitRef[]> GetCommits(string sourceBranch, string targetBranch)
{
VssConnection conn = new(new Uri(this._azureDevOpsUrl), new VssBasicCredential(string.Empty, pat));
GitHttpClient client = conn.GetClient<GitHttpClient>();
List<GitCommitRef> commits = [];
try
{
List<GitCommitRef> res = await client.GetCommitsAsync(projectname, reponame, new GitQueryCommitsCriteria
{
ItemVersion = new GitVersionDescriptor
{
// I also tried refs/heads/{sourceBranch} and refs/heads/{targetBranch}, didnt work either
VersionType = GitVersionType.Branch,
Version = sourceBranch
},
CompareVersion = new GitVersionDescriptor
{
VersionType = GitVersionType.Branch,
Version = targetBranch
}
});
if (res != null)
{
commits.AddRange(res);
}
}
catch (Exception ex)
{
ConsoleEx.Throw($"Error fetching commits: {ex.Message}");
}
return commits.ToArray();
}
Share
Improve this question
edited Mar 14 at 1:53
Knyrps
asked Mar 14 at 1:47
KnyrpsKnyrps
1211 silver badge6 bronze badges
2
|
1 Answer
Reset to default 0The corresponding Azure DevOps REST API of the function 'GetCommitsAsync
' called in your code is "Commits - Get Commits". And the corresponding parameter is 'searchCriteria.itemVersion.version
'.
Based on the example "On a branch
" shared in the documentation of this REST API, the acceptable value of the 'searchCriteria.itemVersion.version
' should be the name of the branch (e.g., main
) rather than the full name of the branch (e.g., refs/heads/main
). Similarly to the parameter 'searchCriteriapareVersion.version
'.
I also have attempted this API on my side:
If I set the value of '
searchCriteria.itemVersion.version
' to berefs/heads/main
, I can get the same TF401175 error.If I set the value of '
searchCriteria.itemVersion.version
' to bemain
, it can work fine without any error.
/refs
prefix. – Jeremy Lakeman Commented Mar 14 at 2:25main
) rather than the full name of the branch (e.g.,refs/heads/main
) to the parametersitemVersion.version
andcompareVersion.version
. @Knyrps – Bright Ran-MSFT Commented Mar 21 at 3:03