首页 > 解决方案 > 在 Devops 中查找自定义字段的路径

问题描述

我正在构建一个控制台应用程序,它以编程方式在 Azure DevOps 中创建工作项。到目前为止,我已经成功地将值设置为预定字段。例如,通过执行以下代码

`

        Uri uri = new Uri(_uri);
        string personalAccessToken = _personalAccessTocken;
        string project = _project;

        // Creating credentials using PAT
        VssBasicCredential credentials = new VssBasicCredential(string.Empty, _personalAccessTocken);

        JsonPatchDocument patchDocument = new JsonPatchDocument();

        //add fields and their values to the patch document
        // See this link below to find out the path of Work Item Field:
        // https://docs.microsoft.com/en-us/azure/devops/boards/work-items/guidance/work-item-field?view=azure-devops

        patchDocument.Add(new JsonPatchOperation()
        {
            Operation = Operation.Add,
            Path = "/fields/System.Title",
            Value = "Test - Please Ignore"
        }`

在这里,设置值是成功的,因为我可以在 Microsoft 文档中找到 Title 字段 (/fields/System.Title) 的路径

但是,我遇到了一个名为Errormsgtag的客户创建的自定义字段,由于缺少路径,我无法为其设置值。

问题是:如何找到自定义字段的路径?Microsoft 是否有任何预先确定的规则?

提前致谢

标签: c#azure-devopsworkitem

解决方案


有一个休息 api,您可以在其中通过名称请求 WorkItemField,然后您可以使用带有 ID 的 workitemfielddefinition -> https://docs.microsoft.com/en-us/rest/api/azure/devops /wit/fields/get?view=azure-devops-rest-5.0

我认为客户端 dll 已经包装了这个功能,但我必须查找在哪里......


推荐阅读