我正在尝试使用 Microsoft.TeamFoundationService.Client
api 创建工作项,但每次我尝试创建工作项时都会失败并出现错误
New work item updates must specify Area and Iteration node ids.
到目前为止,我有以下内容:
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()
});
有什么想法吗?提前致谢。
最佳答案
改变
Path = "/Fields/System.Title"
到
Path = "/fields/System.Title"
对我有用。
关于c# - TFS rest API-创建工作项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42510453/