question

LoveToCode-0935 avatar image
0 Votes"
LoveToCode-0935 asked LoveToCode-0935 commented

Creating new workitems (VB.net ) using json

Hi, I'm creating new work items (devops) using vb.net. I can create a single work item with just a single property but when I try to add a second property I don't see the work item getting created at all. Below is my code.

                Dim JSDocument = New JsonPatchDocument
                 Dim JDocOpearion = New JsonPatchOperation
    
                 JSDocument.Add(JDocOpearion)
    
                 With JDocOpearion
                     .Path = "/fields/System.Title"
                     .Operation = Microsoft.VisualStudio.Services.WebApi.Patch.Operation.Add
    
                     .Value = Txt_WITTitle.Text
                 End With
      
 /* If I comment the below upto End With I can see a single work item */

                 JSDocument.Add(JDocOpearion)
                 With JDocOpearion
    
                     .Path = "/fields/System.Description"
                     .Operation = Microsoft.VisualStudio.Services.WebApi.Patch.Operation.Add
                     .Value = "This is a description"
                 End With
    
                 Dim a As Object
                 a = WClient.CreateWorkItemAsync(JSDocument, "Destination Project", "Epic")
dotnet-visual-basic
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

Viorel-1 avatar image
0 Votes"
Viorel-1 answered LoveToCode-0935 commented

Try adding JDocOpearion = New JsonPatchOperation before the second JSDocument.Add(JDocOpearion).

(Also consider reordering the statements, executing JSDocument.Add after creating and filling the operation objects).

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thank you - it was very helpful. But I would like to write my own api - in vb.net, can you point me to some resources.

0 Votes 0 ·