【发布时间】:2019-01-30 11:09:56
【问题描述】:
我正在尝试使用 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;
}
}
}
谢谢。
【问题讨论】:
-
添加您的示例。没有源代码很难找到错误))也许这个链接对你有用:azure devops rest api add and edit work item links
-
@ShamraiAleksander 请看一个我用过的例子。谢谢。
标签: azure-devops azure-devops-rest-api