gpt4 book ai didi

azure-devops - Azure 开发运营 : create a comment on behalf of another user

转载 作者:行者123 更新时间:2023-12-04 01:49:23 35 4
gpt4 key购买 nike

我正在寻找一种方法来代表另一个用户(模拟另一个用户)向工作项添加评论。

        VssConnection connection = new VssConnection(new Uri(url), new VssClientCredentials());
WorkItemTrackingHttpClient client = connection.GetClient<WorkItemTrackingHttpClient>();

patchDocument.Add(
new JsonPatchOperation()
{
Operation = Operation.Add,
Path = "/fields/System.History",
Value = "Sample comment 1"
}
);

await client.UpdateWorkItemAsync(patchDocument, id);

最佳答案

要在 Azure DevOps 中对工作项创建评论(或代表某人进行更改),您需要在补丁文档中设置 System.ChangedBy 字段并使用 bypassRules :真

        WorkItemTrackingHttpClient client = connection.GetClient<WorkItemTrackingHttpClient>();

patchDocument.Add(
new JsonPatchOperation()
{
Operation = Operation.Add,
Path = "/fields/System.History",
Value = "Sample comment 1"
}
);
patchDocument.Add(
new JsonPatchOperation()
{
Operation = Operation.Add,
Path = "/fields/System.ChangedBy",
Value = "user@onbehalfof.com" //can be valid user id (guid) or user email (domain\alias for onprem).
});

await client.UpdateWorkItemAsync(patchDocument, id, bypassRules:true);

此外,为了能够设置 bypassRules:true - 执行操作的身份必须具有适当的权限:“绕过工作项更新规则”

关于azure-devops - Azure 开发运营 : create a comment on behalf of another user,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53964647/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com