1

All

Below is code for creating a work item.

The "\r\n" in the string description is not recognized, so the description text of newly created item is on one line.

How to create a work item with multi-line description with code, thanks.

    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;
    }
Ming
  • 379
  • 1
  • 6
  • 20

3 Answers3

2

For markdown (wiki format). It will be available in the future. This feature is in the delivery plan of Azure DevOps team: Azure DevOps Feature Timeline

enter image description here

Shamrai Aleksander
  • 13,096
  • 3
  • 24
  • 31
1

Use <br> instead of \r\n. Powershell example:

$pat = '<pat>'
$url = 'https://dev.azure.com/<org>/<project>/_apis/wit/workitems/$Task?api-version=6.1-preview.3'


$body = '[{"op":"add","path":"/fields/System.Title","from":null,"value":"Sample task"}, {"op":"add","path":"/fields/System.Description","from":null,"value":"my line1<br>my line2<br>my line3"}]'


$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f "",$pat)))

Invoke-RestMethod -Uri $url -Method Post -ContentType "application/json-patch+json" -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)} -Body $body

Result:

enter image description here

Shamrai Aleksander
  • 13,096
  • 3
  • 24
  • 31
  • Thanks, Shamrai. Is it possible to display Wiki format correctly in description? – Ming Mar 22 '21 at 05:34
  • @Ming, Basically no. But you can try solution here: https://stackoverflow.com/questions/58982449/azure-devops-markdown-support-in-user-story-description-acceptance-criteria, https://marketplace.visualstudio.com/items?itemName=cschleiden.markdown – Shamrai Aleksander Mar 23 '21 at 13:45
0

Also, Is it possible to display Wiki format correctly in description?

wiki format example:

h1. USN-4883-1: Linux kernel vulnerabilities

20 March 2021

Several security issues were fixed in the Linux kernel.

h2. Releases

  • [Ubuntu 18.04 LTS|https://ubuntu.com/security/notices?release=bionic]
  • [Ubuntu 16.04 LTS|https://ubuntu.com/security/notices?release=xenial]
  • [Ubuntu 14.04 ESM|https://ubuntu.com/security/notices?release=trusty]

h2. Packages

  • [linux|/security/cve?package=linux]
    • Linux kernel
  • [linux-aws|/security/cve?package=linux-aws]
    • Linux kernel for Amazon Web Services (AWS) systems
  • [linux-aws-hwe|/security/cve?package=linux-aws-hwe]
    • Linux kernel for Amazon Web Services (AWS-HWE) systems
  • [linux-azure|/security/cve?package=linux-azure]
    • Linux kernel for Microsoft Azure Cloud systems
  • [linux-azure-4.15|/security/cve?package=linux-azure-4.15]
    • Linux kernel for Microsoft Azure Cloud systems
  • [linux-gcp|/security/cve?package=linux-gcp]
    • Linux kernel for Google Cloud Platform (GCP) systems
  • [linux-gcp-4.15|/security/cve?package=linux-gcp-4.15]
    • Linux kernel for Google Cloud Platform (GCP) systems
  • [linux-hwe|/security/cve?package=linux-hwe]
    • Linux hardware enablement (HWE) kernel
  • [linux-kvm|/security/cve?package=linux-kvm]
    • Linux kernel for cloud environments

h2. Details

Adam Nichols discovered that heap overflows existed in the iSCSI subsystem

in the Linux kernel. A local attacker could use this to cause a denial of

service (system crash) or possibly execute arbitrary code. (

[CVE-2021-27365|/security/CVE-2021-27365]

Adam Nichols discovered that the iSCSI subsystem in the Linux kernel did

not properly restrict access to iSCSI transport handles. A local attacker

could use this to cause a denial of service or expose sensitive information

(kernel pointer addresses). (

[CVE-2021-27363|/security/CVE-2021-27363]

Adam Nichols discovered that an out-of-bounds read existed in the iSCSI

subsystem in the Linux kernel. A local attacker could use this to cause a

denial of service (system crash) or expose sensitive information (kernel

memory). (

[CVE-2021-27364|/security/CVE-2021-27364]

h2. Update instructions

The problem can be corrected by updating your system to the following package versions:

h5. Ubuntu 18.04

  • [linux-image-4.15.0-1081-raspi2|https://launchpad.net/ubuntu/+source/linux-raspi2]
  • [4.15.0-1081.86|https://launchpad.net/ubuntu/+source/linux-raspi2/4.15.0-1081.86]
  • linux-image-powerpc-e500mc-4.15.0.139.126
  • [linux-image-4.15.0-1096-aws|https://launchpad.net/ubuntu/+source/linux-aws]
  • [4.15.0-1096.103|https://launchpad.net/ubuntu/+source/linux-aws/4.15.0-1096.103]
  • [linux-image-4.15.0-139-lowlatency|https://launchpad.net/ubuntu/+source/linux]
  • [4.15.0-139.143|https://launchpad.net/ubuntu/+source/linux/4.15.0-139.143]
  • linux-image-gcp-lts-18.04-4.15.0.1095.113
  • [linux-image-4.15.0-1087-kvm|https://launchpad.net/ubuntu/+source/linux-kvm]
  • [4.15.0-1087.89|https://launchpad.net/ubuntu/+source/linux-kvm/4.15.0-1087.89]
  • linux-image-oracle-lts-18.04-4.15.0.1067.77
  • [linux-image-4.15.0-1095-gcp|https://launchpad.net/ubuntu/+source/linux-gcp-4.15]
  • [4.15.0-1095.108|https://launchpad.net/ubuntu/+source/linux-gcp-4.15/4.15.0-1095.108]
  • linux-image-virtual-4.15.0.139.126
  • [linux-image-4.15.0-139-generic-lpae|https://launchpad.net/ubuntu/+source/linux]
  • [4.15.0-139.143|https://launchpad.net/ubuntu/+source/linux/4.15.0-139.143]
  • linux-image-snapdragon-4.15.0.1098.101
  • linux-image-powerpc64-emb-4.15.0.139.126
  • [linux-image-4.15.0-1067-oracle|https://launchpad.net/ubuntu/+source/linux-oracle]
  • [4.15.0-1067.75|https://launchpad.net/ubuntu/+source/linux-oracle/4.15.0-1067.75]
  • linux-image-aws-lts-18.04-4.15.0.1096.99
  • [linux-image-4.15.0-1110-azure|https://launchpad.net/ubuntu/+source/linux-azure-4.15]
  • [4.15.0-1110.122|https://launchpad.net/ubuntu/+source/linux-azure-4.15/4.15.0-1110.122]

h5. Ubuntu 16.04

  • linux-image-powerpc-e500mc-4.4.0.206.212

  • [linux-image-4.4.0-206-powerpc-smp|https://launchpad.net/ubuntu/+source/linux]

  • [4.4.0-206.238|https://launchpad.net/ubuntu/+source/linux/4.4.0-206.238]

  • [linux-image-4.4.0-206-powerpc-e500mc|https://launchpad.net/ubuntu/+source/linux]

  • [4.4.0-206.238|https://launchpad.net/ubuntu/+source/linux/4.4.0-206.238]

  • [linux-image-4.15.0-1096-aws|https://launchpad.net/ubuntu/+source/linux-aws-hwe]

  • [4.15.0-1096.103~16.04.1|https://launchpad.net/ubuntu/+source/linux-aws-hwe/4.15.0-1096.103~16.04.1]

  • linux-image-generic-hwe-16.04-4.15.0.139.134

  • [linux-image-4.15.0-139-lowlatency|https://launchpad.net/ubuntu/+source/linux-hwe]

  • [4.15.0-139.143~16.04.1|https://launchpad.net/ubuntu/+source/linux-hwe/4.15.0-139.143~16.04.1]

  • linux-image-virtual-hwe-16.04-4.15.0.139.134

  • linux-image-virtual-4.4.0.206.212

  • [linux-image-4.15.0-139-generic-lpae|https://launchpad.net/ubuntu/+source/linux-hwe]

  • [4.15.0-139.143~16.04.1|https://launchpad.net/ubuntu/+source/linux-hwe/4.15.0-139.143~16.04.1]

  • [linux-image-4.4.0-206-generic-lpae|https://launchpad.net/ubuntu/+source/linux]

  • [4.4.0-206.238|https://launchpad.net/ubuntu/+source/linux/4.4.0-206.238]

  • linux-image-snapdragon-4.4.0.1152.144

  • linux-image-powerpc64-smp-4.4.0.206.212

  • [linux-image-4.15.0-139-generic|https://launchpad.net/ubuntu/+source/linux-hwe]

  • [4.15.0-139.143~16.04.1|https://launchpad.net/ubuntu/+source/linux-hwe/4.15.0-139.143~16.04.1]

  • [linux-image-4.4.0-206-lowlatency|https://launchpad.net/ubuntu/+source/linux]

  • [4.4.0-206.238|https://launchpad.net/ubuntu/+source/linux/4.4.0-206.238]

  • linux-image-gke-4.15.0.1095.96

  • [linux-image-4.4.0-206-powerpc64-smp|https://launchpad.net/ubuntu/+source/linux]

  • [4.4.0-206.238|https://launchpad.net/ubuntu/+source/linux/4.4.0-206.238]

  • linux-image-azure-edge-4.15.0.1110.101

  • [linux-image-4.15.0-1110-azure|https://launchpad.net/ubuntu/+source/linux-azure]

  • [4.15.0-1110.122~16.04.1|https://launchpad.net/ubuntu/+source/linux-azure/4.15.0-1110.122~16.04.1]

  • linux-image-generic-4.4.0.206.212

  • [linux-image-4.4.0-1124-aws|https://launchpad.net/ubuntu/+source/linux-aws]

  • [4.4.0-1124.138|https://launchpad.net/ubuntu/+source/linux-aws/4.4.0-1124.138]

  • linux-image-oem-4.15.0.139.134

  • linux-image-aws-4.4.0.1124.129

  • linux-image-kvm-4.4.0.1090.88

  • linux-image-powerpc-smp-4.4.0.206.212

  • linux-image-generic-lpae-4.4.0.206.212

  • [linux-image-4.4.0-206-powerpc64-emb|https://launchpad.net/ubuntu/+source/linux]

  • [4.4.0-206.238|https://launchpad.net/ubuntu/+source/linux/4.4.0-206.238]

  • linux-image-gcp-4.15.0.1095.96

  • linux-image-lowlatency-hwe-16.04-4.15.0.139.134

After a standard system update you need to reboot your computer to make

all the necessary changes.

ATTENTION: Due to an unavoidable ABI change the kernel updates have

been given a new version number, which requires you to recompile and

reinstall all third party kernel modules you might have installed.

Unless you manually uninstalled the standard kernel metapackages

(e.g. linux-generic, linux-generic-lts-RELEASE, linux-virtual,

linux-powerpc), a standard system upgrade will automatically perform

this as well.

h2. References

  • [CVE-2021-27365|https://people.canonical.com/~ubuntu-security/cve/CVE-2021-27365]
  • [CVE-2021-27363|https://people.canonical.com/~ubuntu-security/cve/CVE-2021-27363]
  • [CVE-2021-27364|https://people.canonical.com/~ubuntu-security/cve/CVE-2021-27364]
Ming
  • 379
  • 1
  • 6
  • 20