我正在密切关注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'>
我所有的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>();
答案 0 :(得分:0)
我们与之合作:
var client = new WorkItemTrackingHttpClient(new Uri(uri), cred);
代替:
var conn = new VssConnection(new Uri(uri), cred);
var client = conn.GetClient<WorkItemTrackingHttpClient>();