How to add an additional program to the list of existing programs using a PATCH request in Jira Align
Summary
This article shows what request body should be used in order to add additional program(s) to the list of existing programs and not replace them.
Solution
There are two options available:
1- Provide in the request body the exact list of IDs in the array of all the IDs of the program you want to have (existing and new ones).
[
{
"op": "add",
"path": "/additionalProgramIds/",
"value":[1111, 1112]
}
]
If you do not provide the complete list of IDs, the existing ones will be removed as this replaces the existing values with the ones specified in the body.
As a result, the above body will replace whatever is existing with the new array containing the IDs 1111 and 1112.
2- Provide in the request body only the id(s) you want to add to the array list:
[
{
"op": "add",
"path": "/additionalProgramIds/-",
"value": 1111
}
]
or more than one ID:
[
{
"op": "add",
"path": "/additionalProgramIds/-",
"value": 1111
},
{
"op": "add",
"path": "/additionalProgramIds/-",
"value": 1112
}
]
The above body will add the program with id 1111 (and 1112) to the existing list of arrays.
Notice the extra hyphen '-' at the end path and the type of the value that is passed.