【发布时间】:2019-01-24 23:28:17
【问题描述】:
我正在尝试使用 Microsoft.TeamFoundationService.Client api 创建一个工作项,但每次我尝试创建工作项时都会失败并出现错误
新的工作项更新必须指定区域和迭代节点 ID。
到目前为止,我有以下内容:
var connection = new VssConnection(baseUrl, vssBasicCredential);
var witClient = connection.GetClient<WorkItemTrackingHttpClient>();
var patchDocument = new JsonPatchDocument();
patchDocument.Add(new JsonPatchOperation
{
Operation = Operation.Add,
Path = "/Fields/System.Title",
Value = title
});
...
var newlyCreatedUserStory = witClient.CreateWorkItemAsync(patchDocument,
testProject.Id,
"User Story").Result;
此时抛出异常。我也尝试添加 Area 和 Interation 节点的值:
patchDocument.Add(new JsonPatchOperation
{
Operation = Operation.Add,
Path = "/Fields/System.AreaId",
Value = parentWorkItem.Fields["System.AreaId"].ToString()
});
patchDocument.Add(new JsonPatchOperation
{
Operation = Operation.Add,
Path = "/Fields/System.AreaPath",
Value = parentWorkItem.Fields["System.AreaPath"].ToString()
});
patchDocument.Add(new JsonPatchOperation
{
Operation = Operation.Add,
Path = "/Fields/System.TeamProject",
Value = parentWorkItem.Fields["System.TeamProject"].ToString()
});
patchDocument.Add(new JsonPatchOperation
{
Operation = Operation.Add,
Path = "/Fields/System.NodeName",
Value = parentWorkItem.Fields["System.NodeName"].ToString()
});
patchDocument.Add(new JsonPatchOperation
{
Operation = Operation.Add,
Path = "/Fields/System.AreaLevel1",
Value = parentWorkItem.Fields["System.AreaLevel1"].ToString()
});
patchDocument.Add(new JsonPatchOperation
{
Operation = Operation.Add,
Path = "/Fields/System.IterationId",
Value = parentWorkItem.Fields["System.IterationId"].ToString()
});
patchDocument.Add(new JsonPatchOperation
{
Operation = Operation.Add,
Path = "/Fields/System.IterationPath",
Value = parentWorkItem.Fields["System.IterationPath"].ToString()
});
patchDocument.Add(new JsonPatchOperation
{
Operation = Operation.Add,
Path = "/Fields/System.IterationLevel1",
Value = parentWorkItem.Fields["System.IterationLevel1"].ToString()
});
有什么想法吗?提前致谢。
【问题讨论】:
-
没有
Microsoft.TeamFoundationService.Clientapi,你在使用Microsoft.TeamFoundationServer.Client.NET 客户端库visualstudio.com/en-us/docs/integrate/get-started/… 吗?您使用的是哪个 TFS 版本?这与 TFS 2015 及更高版本以及 Visual Studio Team Services 集成。 -
你是对的 - 抱歉打错了。我正在使用 Visual Studio 在线进行测试,但它将与 Visual Studio Team Services Server 2015 一起使用。我可能应该补充一点,我正在.Net 核心中开发它,所以我使用的是
Microsoft.TeamFoundationServer.Clientlibrary 的 15.113.0-preview 版本跨度>