Scenario
You want to automate updating of List Box type variable in Digital.ai Release, formerly XebiaLabs XL Release, using the REST API so that you can add multiple list items to it.
Environment
Digital.ai Release, REST API
Steps to Perform
1. Find the variable ID of the variable you want to update
For this, run a GET call against your Release that contains variables.
http://localhost:5516/api/v1/releases/Applications/Release183308661/variables
It will produce output like below.
[
{
"id": "Applications/Release183308661/Variable161627602",
"type": "xlrelease.StringVariable",
"$token": "e25e975c-01b9-4377-8b31-053ab62cf214",
"$createdBy": "admin",
"$createdAt": "2017-07-18T07:41:33.220+0200",
"$lastModifiedBy": "admin",
"$lastModifiedAt": "2017-07-18T22:13:51.993+0200",
"key": "usernames",
"requiresValue": false,
"showOnReleaseStart": false,
"label": "usernames",
"valueProvider": {
"id": "Applications/Release183308661/Variable161627602/valueProvider",
"type": "xlrelease.ListOfStringValueProviderConfiguration",
"$token": "c8f850c7-6747-4514-b84c-530a4640f976",
"$createdBy": "admin",
"$createdAt": "2017-07-18T07:41:33.221+0200",
"$lastModifiedBy": "admin",
"$lastModifiedAt": "2017-07-18T22:13:51.891+0200",
"variable": "Applications/Release183308661/Variable161627602",
"values": [
"shashank"
]
}
},
{
"id": "Applications/Release183308661/Variable881681321",
"type": "xlrelease.StringVariable",
"$token": "3c4b08b5-8d5f-40d8-8474-0a1555cbcd0f",
"$createdBy": "admin",
"$createdAt": "2017-07-18T08:20:31.125+0200",
"$lastModifiedBy": "admin",
"$lastModifiedAt": "2017-07-18T08:20:31.125+0200",
"key": "userid",
"requiresValue": false,
"showOnReleaseStart": false,
"label": "userid",
"description": "User IDs",
"value": "shashank"
}
]
You can see that I have 2 variables here. userid & usernames. usernames is a List Box type variable with variable ID Applications/Release183308661/Variable161627602. This List Box has only 1 list item i.e. shashank.
2. Copy the JSON skeleton of this variable. Copy below section only
{
"id": "Applications/Release183308661/Variable161627602",
"type": "xlrelease.StringVariable",
"$token": "e25e975c-01b9-4377-8b31-053ab62cf214",
"$createdBy": "admin",
"$createdAt": "2017-07-18T07:41:33.220+0200",
"$lastModifiedBy": "admin",
"$lastModifiedAt": "2017-07-18T22:13:51.993+0200",
"key": "usernames",
"requiresValue": false,
"showOnReleaseStart": false,
"label": "usernames",
"valueProvider": {
"id": "Applications/Release183308661/Variable161627602/valueProvider",
"type": "xlrelease.ListOfStringValueProviderConfiguration",
"$token": "c8f850c7-6747-4514-b84c-530a4640f976",
"$createdBy": "admin",
"$createdAt": "2017-07-18T07:41:33.221+0200",
"$lastModifiedBy": "admin",
"$lastModifiedAt": "2017-07-18T22:13:51.891+0200",
"variable": "Applications/Release183308661/Variable161627602",
"values": [
"shashank"
]
}
}
3. Update your variable
For this, we need to run a PUT call and supply a payload(JSON) with additional list values. Suppose, I want to add xlr_dev & xlr_admin as list items. To do this, I will use the JSON skeleton copied from the step above and add two more users to it.
Below is the PUT call.
http://localhost:5516/api/v1/releases/Applications/Release183308661/Variable161627602
{
"id": "Applications/Release183308661/Variable161627602",
"type": "xlrelease.StringVariable",
"$token": "e25e975c-01b9-4377-8b31-053ab62cf214",
"$createdBy": "admin",
"$createdAt": "2017-07-18T07:41:33.220+0200",
"$lastModifiedBy": "admin",
"$lastModifiedAt": "2017-07-18T22:13:51.993+0200",
"key": "usernames",
"requiresValue": false,
"showOnReleaseStart": false,
"label": "usernames",
"valueProvider": {
"id": "Applications/Release183308661/Variable161627602/valueProvider",
"type": "xlrelease.ListOfStringValueProviderConfiguration",
"$token": "c8f850c7-6747-4514-b84c-530a4640f976",
"$createdBy": "admin",
"$createdAt": "2017-07-18T07:41:33.221+0200",
"$lastModifiedBy": "admin",
"$lastModifiedAt": "2017-07-18T22:13:51.891+0200",
"variable": "Applications/Release183308661/Variable161627602",
"values": [
"shashank",
"xlr_dev",
"xlr_admin"
]
}
}
It will produce an output similar to the JSON above and will update your variable in XL Release GUI.
Caveats
You need to copy JSON ONLY for the variable which is of type List Box. And after this, you need to add the values before supplying them to the PUT call as payload.
Comments
Please sign in to leave a comment.