简体   繁体   中英

Updates a single work item Azure Devops using Asp.net

I am trying to update work item in Azure devops using this API: https://docs.microsoft.com/en-us/rest/api/azure/devops/wit/work%20items/update?view=azure-devops-rest-5.1#update-a-field . But i can't find the way to do this.

You should use http client to call Rest API. Sample code as below:

private readonly WorkItemTrackingHttpClient _workItemTrackingHttpClient;
public RestApi(string baseUrl, string pat)
{
    var vssConnection = new VssConnection(new Uri(baseUrl), new VssBasicCredential(string.Empty, pat));

    _workItemTrackingHttpClient = vssConnection.GetClient<WorkItemTrackingHttpClient>();

    var document = new JsonPatchDocument();
    document.Add(new JsonPatchOperation()
    {
        Operation = Operation.Add,
        Path = "/fields/Microsoft.VSTS.Scheduling.Effort",
        Value = 1
    });

    var workItem = _workItemTrackingHttpClient.UpdateWorkItemAsync(document, 233843).Result;
}

Besides, you could also use client API, details you could take a look at our official doc here-- Fetch work items with queries programmatically in Azure DevOps Services

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM