Azure DevOps 客户端 SDK:使用 TestManagementHttpClient.GetTestResultsByBuildAsync2 会引发身份验证错误

发布于 2025-01-11 22:06:40 字数 720 浏览 1 评论 0原文

我正在使用 用于 Azure DevOps 的 .NET 客户端库 从构建尝试中获取测试结果。以下内容会引发身份验证错误,Microsoft.VisualStudio.Services.Common.VssUnauthorizedException: VS30063: You 无权访问 https://dev.azure.com。

var testClient = connection.GetClient<TestManagementHttpClient>();

var testResults = await testClient.GetTestResultsByBuildAsync2(
                project: project,
                buildId: ID);

我正在使用范围有限的 PAT读取并执行构建和测试。不知道为什么我会收到此错误。还有其他方法可以获取每次尝试的测试结果吗?我可以使用相同的连接来调用 GetTestResultDetailsForBuildAsync,但不幸的是,它列出了所有尝试的结果,而我只需要最后一个。

I am using the .NET client library for Azure DevOps to get test results from a build attempt. The following throws an authentication error, Microsoft.VisualStudio.Services.Common.VssUnauthorizedException: VS30063: You are not authorized to access https://dev.azure.com.

var testClient = connection.GetClient<TestManagementHttpClient>();

var testResults = await testClient.GetTestResultsByBuildAsync2(
                project: project,
                buildId: ID);

I am using a PAT that is scoped to read and execute Builds and Tests. Not sure why I'm getting this error. Is there another way to get test results per attempt? I am able to use this same connection to call GetTestResultDetailsForBuildAsync but unfortunately, that lists results for all the attempts and I just need the last one.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

难理解 2025-01-18 22:06:40

请尝试以下任一方法来解决 Microsoft.VisualStudio.Services.Common.VssUnauthorizedException: VS30063: 您无权访问 https://dev.azure.com. 错误:

  1. 按照的建议清理缓存Marina Liu:执行
    regedit ->清理下面的钥匙
    HKEY_CURRENT_USER\Software\Microsoft\VSCommon\14.0\ClientServices\TokenStorage\VisualStudio\VssApp
    ->重启VS->使用您自己的凭据运行您的项目。

  2. 检查个人访问令牌是否已过期或是否使用正确的范围创建

参考:VS30063:您无权访问 https://dev.azure.com?尝试使用 PAT 令牌在 Azure DevOps 项目中注册专用代理池时出错 - Microsoft 问答c# - VS30063:您无权访问 https://dev.azure.com - 堆栈内存溢出Visual Studio 反馈

Try either of the following ways to resolve Microsoft.VisualStudio.Services.Common.VssUnauthorizedException: VS30063: You are not authorized to access https://dev.azure.com. error:

  1. Clean the cache as suggested by Marina Liu:Execute
    regedit -> clean key(s) under
    HKEY_CURRENT_USER\Software\Microsoft\VSCommon\14.0\ClientServices\TokenStorage\VisualStudio\VssApp
    -> restart VS -> run your project with your own credential.

  2. Check whether Personal Access Token has expired or created with the right Scope or not

References: VS30063: You are not authorized to access https://dev.azure.com? Error while trying to register Private agent Pool in Azure DevOps Project using PAT token - Microsoft Q&A , c# - VS30063: You are not authorized to access https://dev.azure.com - Stack Overflow and Visual Studio Feedback

神回复 2025-01-18 22:06:40

我遇到了同样的问题,但所有建议都没有帮助。我还可以调用其他一些方法,但不能调用 GetTestResultsByBuildAsync
幸运的是,我注意到有不同类型的客户端:

TestResultsHttpClient testClient1 = connection.GetClient<TestResultsHttpClient>(); 
TestManagementHttpClient testClient2 = connection.GetClient<TestManagementHttpClient>();

如果我使用 testClient1,那么调用下面的代码工作正常,但当我使用 testClient2 时,会因身份验证错误而失败。:

List<ShallowTestCaseResult> allTestResults =
   await testClient.GetTestResultsByBuildAsync(ProjectName, buildId);

请尝试使用 TestResultsHttpClient 而不是 TestManagementHttpClient

I had the same issue and none of the suggestions helped. I was also able to call some other methods but not the GetTestResultsByBuildAsync.
Luckily, I have noticed that there are different types of clients:

TestResultsHttpClient testClient1 = connection.GetClient<TestResultsHttpClient>(); 
TestManagementHttpClient testClient2 = connection.GetClient<TestManagementHttpClient>();

Then calling the code below worked fine if I used testClient1 and failed with an authentication error when I used testClient2.:

List<ShallowTestCaseResult> allTestResults =
   await testClient.GetTestResultsByBuildAsync(ProjectName, buildId);

Please try to use TestResultsHttpClient instead of TestManagementHttpClient.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文