Azure Devops:无法使用 TFS 客户端库获取工件内容 zip

Azure Devops: Fail to get artifact content zip with TFS Client lib

我想下载一个带有 Azure DevOps 服务的项目 API。
在使用 C# 编程时,我选择使用 Microsoft.TeamFoundationServer.Client SDK,版本:16.153.0 作为工具。

我确定我有神器。
但是在我使用之后 BuildHttpClient::GetArtifactContentZipAsync(project: "XXX", buildId: buildid, artifactName: "XXX")
获取 zip 流。我收到一条消息异常:
The requested version \"5.1\" of the resource is under preview. The -preview flag must be supplied in the api-version for such requests. For example: \"5.1-preview\"

看来我用错了API的版本,但我真的没有看到任何API将这个版本设置为“5.1-preview”。
有没有办法解决这个问题?或者我应该使用旧版本的 TFS SDK?

我测试了 15.131.1 版本的 Microsoft.TeamFoundationServer.Client SDK,它运行良好,但尝试了 16.153.0 版本但失败了。

示例代码:

static readonly string TFUrl = "https://dev.azure.com/OrgName/";
static readonly string UserPAT = "PAT";

static void Main(string[] args)
{
    try
    {
        int buildId = xx; // update to an existing build definition id
        string artifactName = "drop"; //default artifact name
    //  string project = "projectName";
        ConnectWithPAT(TFUrl, UserPAT);

        Stream zipStream = BuildClient.GetArtifactContentZipAsync(buildId, artifactName).Result; //get content
        using (FileStream zipFile = new FileStream(@"C:\MySite\test.zip", FileMode.Create))
            zipStream.CopyTo(zipFile);
        Console.WriteLine("Done");
    }
    catch (Exception ex)
    {
        Console.WriteLine("Exception: " + ex.Message);
        if (ex.InnerException != null) Console.WriteLine("Detailed Info: " + ex.InnerException.Message);
        Console.WriteLine("Stack:\n" + ex.StackTrace);
    }
}

感谢休的回答。可能是16.153.0版本的SDK有问题
由于某些原因,我应该使用新版本的SDK,所以我选择绕过API并自行下载神器。

首先,我使用BuildHttpClient::GetArtifactContentZipAsync 来获取结构体BuildArtifact 的对象。 然后我在BuildArtifact.Resource.DownloadUrl中找到神器的下载link。 最后我从这个 link.

得到了资源

这样一来,像Auth/Httpdownload这样的一些细节我应该自己处理了。但无论如何我得到了我想要的。

希望在下一个版本的TFS SDK中工作。