无法隐藏工作项中的部署字段

问题描述 投票:0回答:1

我使用这个 rest api 从布局中隐藏字段,但是它总是因字段“部署”而失败:

示例 url 和 json:

https://dev.azure.com/myNewDevOpsOrg/_apis/work/processes/035ff023-2a9c-4f38-b76e-e301dd6fdad6/workItemTypes/processName.Bug/layout/groups/Agile.Bug.Bug.Deployment/Controls/Deployments?api-version=7.1
{
  "visible": false
}

我得到的错误:

Invoke-RestMethod:  {   "$id": "1",   "innerException": null,   "message": "VS402645: The field Deployments does not exists in work item type TOTO-16.Bug",  
"typeName": "Microsoft.TeamFoundation.WorkItemTracking.Server.Metadata.ProcessWorkItemTypeFieldDoesNotExistException,
Microsoft.TeamFoundation.WorkItemTracking.Server",   "typeKey": "ProcessWorkItemTypeFieldDoesNotExistException",   "errorCode": 0,          
"eventId": 3200 }

页面布局

"id": "Section3",
                    "groups": [
                        {
                            "id": "Agile.Bug.Bug.Deployment",
                            "inherited": true,
                            "label": "Deployment",
                            "isContribution": false,
                            "visible": true,
                            "controls": [
                                {
                                    "id": "Deployments",
                                    "inherited": true,
                                    "label": "",
                                    "controlType": "DeploymentsControl",
                                    "readOnly": false,
                                    "watermark": "",
                                    "metadata": "",
                                    "visible": true,
                                    "isContribution": false
                                }
                            ]
                        },

所以我不明白为什么它不起作用,我提供了所需的信息(ids),但他仍然找不到......

azure powershell azure-devops azure-rest-api
1个回答
0
投票

我可以重现相同的错误以隐藏相同的字段。

你可以在body中添加

"controlType": "DeploymentsControl"
,然后就可以了。

enter image description here

示例 PowerShell 脚本:

# Define your parameters
$personalAccessToken = "PAT"

# Create the authorization header
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(":$($personalAccessToken)"))

# Define the API URL
$uri = "https://dev.azure.com/myorg/_apis/work/processes/22fxx6eb-8sse-4cc0-b197-b3582xx3c6a/workItemTypes/WadeAgile3.Bug/layout/groups/Agile.Bug.Bug.Deployment/Controls/Deployments?api-version=7.1"

# Define the JSON body for the request
$jsonBody = @"
{
    "visible": false,
    "controlType": "DeploymentsControl"
}
"@

# Make the REST API call
$response = Invoke-RestMethod -Uri $uri -Method Patch -Body $jsonBody -ContentType "application/json" -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)}

# Output the response
$response

enter image description here

我这边测试过,其他字段,例如自定义字段,不需要该参数。

© www.soinside.com 2019 - 2024. All rights reserved.