我正在尝试使用API在Azure devops中创建/更新工作项。如果项目没有任何关系,则可以创建/更新。但是如果我指定关系例如亲子,然后我得到以下错误:
TF401349:发生意外错误,请验证您的请求,然后重试。
我正在使用JsonPatchDocument创建/更新工作项。下面的示例:
localStorage.getItem(name) == null
}
谢谢。
答案 0 :(得分:0)
在您的示例中我看不到“ rel”的定义。像这样:
patchDocument.Add(new JsonPatchOperation()
{
Operation = Operation.Add,
Path = "/relations/-",
Value = new {
rel = "System.LinkTypes.Hierarchy-Forward",
url = RelUrl,
attributes = new
{
comment = "Comment for the link"
}
}
});
也许您的代码必须是这样的:
JsonPatchOperation AddRelationship(JsonPatchDocument doc, string relname, WorkItem linkedItem, bool isNew, int index)
{
//update link
if (!isNew)
{
return new JsonPatchOperation()
{
Operation = Operation.Replace,
Path = "/relations/" + index + "/attributes/comment",
Value = "comment while update"
};
}
else
return new JsonPatchOperation()
{
Operation = Operation.Add,
Path = "/relations/-",
Value = new { rel = relname, url = linkedItem.Url, attributes = new { comment = "Comment while creating item" } }
};
}