I use this rest api to hide a field from the layout, however it alway fail with the field "deployment" :
Sample url and 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
}
Error i got:
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 }
Layout of the page
"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
}
]
},
So i don't understand why it won't work, i give the information (ids) it needed but he still can't find it...
I can reproduce the same error to hide the same field.
You can add "controlType": "DeploymentsControl"
in the body, then it will work.
Sample PowerShell script:
# 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
Tested on my side, for other field, eg, custom field, the parameter is not needed.