Reputation: 870
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#?
Upvotes: 1
Views: 811
Reputation: 19026
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"
});
Upvotes: 5