cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
983
Views
0
Helpful
3
Replies

POST cliTemplateConfiguration/upload - multiple variables

Gabriel Zapodeanu
Cisco Employee
Cisco Employee

I am working on a script to upload a CLI template to Prime, followed by deployment.

As part of my script I will need to have multiple variables used:

/webacs/api/v1/op/cliTemplateConfiguration/upload

...

"variables" :

  {"variable" : {

   "defaultValue" : "",

   "description" : "IP address",

   "displayLabel" : "",

   "name" : "RemoteClient",

   "rangeFrom" : "",

   "rangeTo" : "",

   "required" : True,

   "type" : "IPv4 Address",

   "validationExpression" : ""

   },

   "variable" : {

   "defaultValue" : "",

   "description" : "VLAN number",

   "displayLabel" : "",

   "name" : "VlanId",

   "rangeFrom" : "",

   "rangeTo" : "",

   "required" : True,

   "type" : "Integer",

   "validationExpression" : ""

   }

}

---

I am able to send one variable to Prime, but not more. The documentation asks for a list of variables. It does not seem to work as a list of variables.

The documentation is not very clear how to actually accomplish this. How do I format the data I need to send to be able to use multiple variables in my code?

1 Accepted Solution

Accepted Solutions

Spencer Zier
Cisco Employee
Cisco Employee

So for JSON, there should be a JSON object "variables" containing a JSON array "variable" of variable objects.

"variables":{

"variable":[

{"name":"Example one","description":"Example",...},

{"name":"Example two","description":"Example",...},

{"name":"Example three","description":"Example",...}

]

}

The square brackets denote that it's an array of objects.

For customers using JSON, we recommend moving to API v2, as the JSON output and input handling for arrays is consistent (in v1, the JSON handler will treat "variable" as an object if it has only one element and an array if it has more than one).

View solution in original post

3 Replies 3

Spencer Zier
Cisco Employee
Cisco Employee

So for JSON, there should be a JSON object "variables" containing a JSON array "variable" of variable objects.

"variables":{

"variable":[

{"name":"Example one","description":"Example",...},

{"name":"Example two","description":"Example",...},

{"name":"Example three","description":"Example",...}

]

}

The square brackets denote that it's an array of objects.

For customers using JSON, we recommend moving to API v2, as the JSON output and input handling for arrays is consistent (in v1, the JSON handler will treat "variable" as an object if it has only one element and an array if it has more than one).

Spencer, Thank you, I will try out the solution and use API v2. I will update with the results.

Thank you for your help. It worked as stated. Example of using two variables: $VlanId and $RemoteClient

list_var = {

   'variable': [

  {'name': 'RemoteClient', 'displayLabel': 'RemoteClient', 'description': 'IP address', 'required': 'True', 'type': 'IPv4 Address'},
   {'name': 'VlanId', 'displayLabel': 'VlanId', 'description': 'VLAN number', 'required': 'True', 'type': 'Integer'}

  ]

}

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: