Azure DevOps中的Ping(@)用户评论 [英] Ping (@) user in Azure DevOps comment

查看:60
本文介绍了Azure DevOps中的Ping(@)用户评论的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我具有下面的方法,该方法将注释发布到Azure DevOps中的工作项.

I have the method below that posts a comment to a work-item in Azure DevOps.

我如何在评论中 @ 用户?

下面的两个示例仅发布了一个字符串,该字符串为 @firstName lastName ,并且未标记用户.

The Two examples below just posts a string that is @firstName lastNameand not tagging the user.

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);
    }
}

推荐答案

如果执行Get操作,您会看到所需的格式:

If you perform Get operation you can see the format you need:

var wi = workitemClient.GetWorkItemAsync("project", id).Result;

wi.Fields ["System.History"] 的值为:

因此格式为:

<a href="#" data-vss-mention="version:2.0,userid"></a>

用用户ID替换 userid ,可以使用

Replace the userid with the User Id, to get it you can use User Entitlements - List Rest API.

这篇关于Azure DevOps中的Ping(@)用户评论的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆