我正在尝试使用API在Azure DevOps中创建/更新工作项。如果该项没有任何关联,我可以成功创建/更新。但是,如果我指定了关联,例如父子关系,则会出现以下错误:
TF401349:发生了意外错误,请验证您的请求并重试。
我正在使用JsonPatchDocument来创建/更新工作项。以下是示例:
class Example
{
JsonPatchOperation AddRelationship(JsonPatchDocument doc, string rel, WorkItem linkedItem, bool isNew, int index)
{
//update link
if (!isNew)
{
return new JsonPatchOperation()
{
Operation = Operation.Add,
Path = "/relations/" + index,
Value = new { rel, url = linkedItem.Url, attributes = new { comment = "comment while update" } }
};
}
else
return new JsonPatchOperation()
{
Operation = Operation.Add,
Path = "/relations/-",
Value = new { rel, url = linkedItem.Url, attributes = new { comment = "Comment while creating item" } }
};
}
void Save()
{
// some code
doc.Add(AddRelationship(doc, "System.LinkTypes.Hierarchy-Forward", item, isNew, index++));
var workItem = isNew
? witClient.CreateWorkItemAsync(doc, Vsts.Project, issueType, bypassRules: true, validateOnly: Mode == ProcessingMode.ReadOnly).Result
: witClient.UpdateWorkItemAsync(doc, existingWorkItemId.Value, bypassRules: true, validateOnly: Mode == ProcessingMode.ReadOnly).Result;
}
}
}
谢谢。