AzureDevOps - 通过 JsonPatchOperation 创建工作项
要创建工作项,我需要指定其字段,但我在 AzureDevOps 站点上到底在哪里可以看到所有可能的“字段路径”? 我已经编辑了现有的工作项并向其中添加了更多字段,但我似乎无法找到 JsonPatchOperation 所需的“字段路径”。
有什么想法吗?提前致谢!
public static WorkItem CreateWorkItem(VssConnection connection, string title, string type, string description, string tags)
{
string project = "xxx";
// Construct the object containing field values required for the new work item
JsonPatchDocument patchDocument = new JsonPatchDocument();
patchDocument.Add(
new JsonPatchOperation()
{
Operation = Operation.Add,
Path = "/fields/System.Title", <-- field path
Value = title
}
);
patchDocument.Add(
new JsonPatchOperation()
{
Operation = Operation.Add,
Path = "/fields/System.Description", <-- field path
Value = description
}
);
// Get a client
WorkItemTrackingHttpClient workItemTrackingClient = connection.GetClient<WorkItemTrackingHttpClient>();
// Create the new work item
WorkItem newWorkItem = workItemTrackingClient.CreateWorkItemAsync(patchDocument, project, type).Result;
Console.WriteLine("Created work item ID {0} {1}", newWorkItem.Id, newWorkItem.Fields["System.Title"]);
return newWorkItem;
}
To create a workitem I need to specify its fields but where exactly can I see all the possible "field paths" on my AzureDevOps site?
I've edited an existing workitem and added some more fields to it but I cant seem to find the needed "field path" for my JsonPatchOperation.
Any ideas? Thanks in advance!
public static WorkItem CreateWorkItem(VssConnection connection, string title, string type, string description, string tags)
{
string project = "xxx";
// Construct the object containing field values required for the new work item
JsonPatchDocument patchDocument = new JsonPatchDocument();
patchDocument.Add(
new JsonPatchOperation()
{
Operation = Operation.Add,
Path = "/fields/System.Title", <-- field path
Value = title
}
);
patchDocument.Add(
new JsonPatchOperation()
{
Operation = Operation.Add,
Path = "/fields/System.Description", <-- field path
Value = description
}
);
// Get a client
WorkItemTrackingHttpClient workItemTrackingClient = connection.GetClient<WorkItemTrackingHttpClient>();
// Create the new work item
WorkItem newWorkItem = workItemTrackingClient.CreateWorkItemAsync(patchDocument, project, type).Result;
Console.WriteLine("Created work item ID {0} {1}", newWorkItem.Id, newWorkItem.Fields["System.Title"]);
return newWorkItem;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用流程模板编辑器查看组织中的所有字段。
将进程编辑器安装到 VS:

打开字段浏览器:
You can use the process template editor to see all fields in your org.
Install Process Editor to VS:

Open Fields Browser:
另一种方式:使用rest api。
Another way: using the rest api.