question

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

JSON operation .value proprety

Hi, I'm not sure how to use the Source and Rel attributes of .Value property of a json operation object. Below is my code in vb.net.

 JDocOpearion = New JsonPatchOperation
              With JDocOpearion
                  .Path = "/relations/-"
                  .Operation = Microsoft.VisualStudio.Services.WebApi.Patch.Operation.Add
                  Dim link = New WorkItemLink
                  .Value = link.Rel = "System.LinkTypes.Hierarchy-Reverse" _
                  & link.Source.Url = witlink.Source.Url
              End With
dotnet-visual-basic
· 3
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.

Always a great idea to include a valid sample bit of json to go along with your question.

0 Votes 0 ·
    Dim JSDocument = New JsonPatchDocument
                 Dim JDocOpearion = New JsonPatchOperation
    
                 With JDocOpearion
                     .Path = "/fields/System.Title"
                     .Operation = Microsoft.VisualStudio.Services.WebApi.Patch.Operation.Add
                     .Value = Txt_WITTitle.Text
                 End With
    
                 JSDocument.Add(JDocOpearion)
    
    
        
                 Dim a As Object
                 a = WitClient.CreateWorkItemAsync(JSDocument, "Destination Project", "Epic")
0 Votes 0 ·

I can create a new work item with multiple properties fine. My scenario is I have a list of workitems, and I have an option to Add child to a work item.

0 Votes 0 ·

1 Answer

LoveToCode-0935 avatar image
0 Votes"
LoveToCode-0935 answered LoveToCode-0935 edited

I figured it out. here's what I did. @karenpayneoregon. Please suggest if there's also a better way to do. I love to code. Thank you :)

       JDocOpearion = New JsonPatchOperation
    
                 Dim SRCWitem As New WorkItem
                 Dim WitRelations As New WorkItemRelation
    
                 SRCWitem = WitClient.GetWorkItemAsync(SourceWorkItemID).Result
    
                 WitRelations.Rel = "System.LinkTypes.Hierarchy-Reverse"
                 WitRelations.Title = "Azure devops"
                 WitRelations.Url = SRCWitem.Url
    
                 With JDocOpearion
                     .Path = "/relations/-"
                     .Operation = Microsoft.VisualStudio.Services.WebApi.Patch.Operation.Add
                     .Value = WitRelations  /* I added the workitemrelations object */
                 End With
                 JSDocument.Add(JDocOpearion)
    
                 Dim a As Object
                 a = WitClient.CreateWorkItemAsync(JSDocument, ProjectName, "Epic")


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.