【发布时间】:2021-03-26 22:44:20
【问题描述】:
全部
以下是创建工作项的代码。
字符串描述中的“\r\n”无法识别,所以新建项目的描述文本是一行。
如何使用代码创建具有多行描述的工作项,谢谢。
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",
Value = title
}
);
patchDocument.Add(
new JsonPatchOperation()
{
Operation = Operation.Add,
Path = "/fields/System.Description",
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;
}
【问题讨论】:
标签: json azure-devops azure-boards