【问题标题】:Microsoft.TeamFoundation.WorkItemTracking.WebApi failing to GetClient<WorkItemTrackingHttpClient>()Microsoft.TeamFoundation.WorkItemTracking.WebApi 未能 GetClient<WorkItemTrackingHttpClient>()
【发布时间】:2020-04-21 02:30:03
【问题描述】:

我正在密切关注 azure-devops-dotnet-samples CreateBugUsingClientLib() 示例,但是

GetClient<WorkItemTrackingHttpClient>()

正在投掷:

InnerException:{“无法从 System.String 转换或转换为 Microsoft.VisualStudio.Services.Identity.IdentityDescriptor。”} System.Exception {System.ArgumentException}

消息:“将值“Microsoft.IdentityModel.Claims.ClaimsIdentity;stuff\me@contoso.com\”转换为类型“Microsoft.VisualStudio.Services.Identity.IdentityDescriptor”时出错。路径“authenticatedUser.descriptor”

完整示例在这里:https://github.com/Microsoft/azure-devops-dotnet-samples/blob/master/ClientLibrary/Quickstarts/dotnet/WitQuickStarts/Samples/CreateBug.cs

我所有的 NuGet 都是最新的。

// string uri = "https://teams.visualstudio.com/defaultCollection/"
// string pat = "personal access token";
// string project = "Ateam";
// string path = "autobug";
// string title = "you broke it";
// string steps = "you touched it";

var patchDoc = new JsonPatchDocument
{
    new JsonPatchOperation() { Operation = Operation.Add, Path = "/fields/System.Title", Value = title },
    new JsonPatchOperation() { Operation = Operation.Add, Path = "/fields/System.AreaPath", Value = path },
    new JsonPatchOperation() { Operation = Operation.Add, Path = "/fields/Microsoft.VSTS.TCM.ReproSteps", Value = steps },
    new JsonPatchOperation() { Operation = Operation.Add, Path = "/fields/Microsoft.VSTS.Common.Priority", Value = "2" },
    new JsonPatchOperation() { Operation = Operation.Add, Path = "/fields/Microsoft.VSTS.Common.Severity", Value = "2" }
};

var cred = new VssBasicCredential("", pat);
var conn = new VssConnection(new Uri(uri), cred);
var client = conn.GetClient<WorkItemTrackingHttpClient>();

【问题讨论】:

  • 您是如何在代码中定义“stuff\me@contoso.com”的?
  • 这是来自个人访问令牌的内容。

标签: c# azure-devops


【解决方案1】:

我们得到了这个工作:

var client = new WorkItemTrackingHttpClient(new Uri(uri), cred);

代替:

var conn = new VssConnection(new Uri(uri), cred);
var client = conn.GetClient<WorkItemTrackingHttpClient>();

【讨论】:

  • 这对我有用,但我试图理解为什么显式 VssConnection 对象会引发错误。我的理论是 TFS 和 VSS 库之间存在特殊差异。
猜你喜欢
  • 2018-07-30
  • 2023-04-04
  • 1970-01-01
  • 1970-01-01
  • 2011-09-02
  • 2016-06-21
  • 2018-06-18
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多