VSTS 任务创建:缺少必填字段
VSTS Task Creation : Required field missing
我正在尝试在 VSTS
中创建任务,但出现以下 错误。
TF401320: Rule Error for field Task Type. Error code: Required, HasValues, LimitedToValues, AllowsOldValue, InvalidEmpty.
从 Exception
可以明显看出我缺少一个必填字段 Task Type
。现在我无法找到 Task Type
的字段路径。谁能帮我解决这个问题。
下面是我为添加任务而编写的代码:
string discipline = "Research Task";
if (taskDesc.Key.Contains("Configuration"))
{
discipline = "Dev Task";
}
if (taskDesc.Key.Contains("Validation"))
{
discipline = "Quality Task";
}
var workitemtype = "Task";
var document = new JsonPatchDocument();
document.Add(
new JsonPatchOperation()
{
Path = "/fields/Microsoft.VSTS.Common.Discipline",
Operation = Microsoft.VisualStudio.Services.WebApi.Patch.Operation.Add,
Value = discipline
});
document.Add(
new JsonPatchOperation()
{
Path = "/fields/System.Title",
Operation = Microsoft.VisualStudio.Services.WebApi.Patch.Operation.Add,
Value = string.Format("{0} {1}", porIDText, taskDesc.Key)
});
document.Add(new JsonPatchOperation()
{
Path = "/fields/System.AreaPath",
Operation = Microsoft.VisualStudio.Services.WebApi.Patch.Operation.Add,
Value = System.Configuration.ConfigurationManager.AppSettings["AreaPath"]
});
document.Add(
new JsonPatchOperation()
{
Path = "/fields/System.AssignedTo",
Operation = Microsoft.VisualStudio.Services.WebApi.Patch.Operation.Add,
Value = "<name>"
});
document.Add(
new JsonPatchOperation()
{
Path = "/fields/System.Description",
Operation = Microsoft.VisualStudio.Services.WebApi.Patch.Operation.Add,
Value = taskDesc.Value
});
var wi = client.CreateWorkItemAsync(
document,
teamProjectName,
workitemtype).Result;
您可以将任务类型字段添加到任务工作项,但不要添加到布局。
您可以在 Web Access 中检查任务工作项的字段(转到集合页面 > 设置 > 流程 >Select 模板 > 工作项类型 > 任务 > 字段)或通过 REST API。
任务类型字段的设置值:
代码:
document.Add(
new Microsoft.VisualStudio.Services.WebApi.Patch.Json.JsonPatchOperation()
{
Path = "/fields/Microsoft.VSTS.CMMI.TaskType",
Operation = Microsoft.VisualStudio.Services.WebApi.Patch.Operation.Add,
Value = "Type1"
});
我正在尝试在 VSTS
中创建任务,但出现以下 错误。
TF401320: Rule Error for field Task Type. Error code: Required, HasValues, LimitedToValues, AllowsOldValue, InvalidEmpty.
从 Exception
可以明显看出我缺少一个必填字段 Task Type
。现在我无法找到 Task Type
的字段路径。谁能帮我解决这个问题。
下面是我为添加任务而编写的代码:
string discipline = "Research Task";
if (taskDesc.Key.Contains("Configuration"))
{
discipline = "Dev Task";
}
if (taskDesc.Key.Contains("Validation"))
{
discipline = "Quality Task";
}
var workitemtype = "Task";
var document = new JsonPatchDocument();
document.Add(
new JsonPatchOperation()
{
Path = "/fields/Microsoft.VSTS.Common.Discipline",
Operation = Microsoft.VisualStudio.Services.WebApi.Patch.Operation.Add,
Value = discipline
});
document.Add(
new JsonPatchOperation()
{
Path = "/fields/System.Title",
Operation = Microsoft.VisualStudio.Services.WebApi.Patch.Operation.Add,
Value = string.Format("{0} {1}", porIDText, taskDesc.Key)
});
document.Add(new JsonPatchOperation()
{
Path = "/fields/System.AreaPath",
Operation = Microsoft.VisualStudio.Services.WebApi.Patch.Operation.Add,
Value = System.Configuration.ConfigurationManager.AppSettings["AreaPath"]
});
document.Add(
new JsonPatchOperation()
{
Path = "/fields/System.AssignedTo",
Operation = Microsoft.VisualStudio.Services.WebApi.Patch.Operation.Add,
Value = "<name>"
});
document.Add(
new JsonPatchOperation()
{
Path = "/fields/System.Description",
Operation = Microsoft.VisualStudio.Services.WebApi.Patch.Operation.Add,
Value = taskDesc.Value
});
var wi = client.CreateWorkItemAsync(
document,
teamProjectName,
workitemtype).Result;
您可以将任务类型字段添加到任务工作项,但不要添加到布局。
您可以在 Web Access 中检查任务工作项的字段(转到集合页面 > 设置 > 流程 >Select 模板 > 工作项类型 > 任务 > 字段)或通过 REST API。
任务类型字段的设置值:
代码:
document.Add(
new Microsoft.VisualStudio.Services.WebApi.Patch.Json.JsonPatchOperation()
{
Path = "/fields/Microsoft.VSTS.CMMI.TaskType",
Operation = Microsoft.VisualStudio.Services.WebApi.Patch.Operation.Add,
Value = "Type1"
});