我具有下面的方法,该方法将注释发布到Azure DevOps中的工作项。
我如何@
注释中的用户?
下面的两个示例仅发布了@firstName lastName
的字符串,并且未标记用户。
pMessage = "@User you need to take a look at this workitem"
pMessage = "@firstName lastName <mail> you need to take a look at this workitem"
public async Task PingUser(List<int> pId, string pMessage, VssConnection pConnection)
{
WorkItemTrackingHttpClient client = pConnection.GetClient<WorkItemTrackingHttpClient>();
foreach (var id in pId)
{
await client.UpdateWorkItemAsync(
new JsonPatchDocument()
{new JsonPatchOperation(){
Operation = Operation.Add,
Value = pMessage,
Path = "/fields/System.History",
}}, id);
}
}
答案 0 :(得分:2)
如果执行Get操作,您会看到所需的格式:
var wi = workitemClient.GetWorkItemAsync("project", id).Result;
wi.Fields["System.History"]
的值是:
因此格式为:
<a href="#" data-vss-mention="version:2.0,userid"></a>
用用户ID替换userid
,可以使用User Entitlements - List Rest API来获取它。