1

As per MS documentation in order to send a json request to Azure DevOps we should use the following code:

{ "op": "add", "path": "/fields/System.WorkItemType", "value": "Task" }, { "op": "add", "path": "/fields/System.State", "value": "To Do" }

My question is how to use this piece of code from C#?

4
  • Did you look at the "Getting started" link in the documentation? learn.microsoft.com/en-us/rest/api/azure/devops/… Commented Oct 16, 2019 at 0:14
  • Thank you Daniel. I did look at it but did not see where it uses similar code to what I have posted. It is using a url to send the request. Commented Oct 16, 2019 at 0:16
  • Read more closely. There is a section that provides a link to sample code and client libraries you can use from C#. Commented Oct 16, 2019 at 0:20
  • The sample link does not use json code. Thanks. Commented Oct 16, 2019 at 0:27

1 Answer 1

5

In C#, we use Microsoft.VisualStudio.Services.WebApi.Patch.Json.JsonPatchDocument to pack a completed request body Json, then pass it into the method.

See below sample:

var patchDocument = new 
Microsoft.VisualStudio.Services.WebApi.Patch.Json.JsonPatchDocument();
patchDocument.Add(new Microsoft.VisualStudio.Services.WebApi.Patch.Json.JsonPatchOperation() {
                Operation=Operation.Add,
                Path= "/fields/System.WorkItemType",
                Value="Task"
            });
patchDocument.Add(new Microsoft.VisualStudio.Services.WebApi.Patch.Json.JsonPatchOperation()
            {
                Operation = Operation.Add,
                Path = "/fields/System.State",
                Value = "To Do"
            });
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.