06-13-2016 09:02 AM
Hi,
I have a query regarding the Cisco Prime Infrastructure API documentation hosted under URL: https://developer.cisco.com/site/prime-infrastructure/documents/api-reference/rest-api-v3-0/. I am using ReST apis mentioned in the above stated url to fetch inventory data from the Prime Infrastructure (PI) without using the GUI provided from the PI. Similarly I want to create VLAN on a switch using ReST api calls without using GUI.
My query is that can we create VLAN from ReST api calls? If so, is it through Cli templates?
According to the documentation mentioned above, it is said that we can download Cli templates for Configure vlan from the URL mentioned under "Get Cli Templates" section of the documentation and it is also said that we can deploy templates through jobs. Therefore, I followed the documentation and downloaded Cli template for Configure vlan and deployed it through job using the urls mentioned in the documentation, I am getting an error message saying "Invalid variable values" and the vlan is not being created.
Am I missing something here? Any advice for me ?
Thanks in advance
Solved! Go to Solution.
07-03-2016 10:11 PM
Hi,
I have a similar problem : "Invalid var Values for given template's variables"
I've been stuck on this for days. Nothing really shows the error in "ifm_jobscheduler.log"
There is no "pnp_template.log" available.
I only have two variables "interfaceName" and 'vlan_id"
The job runs OK from within Prime.
TEMPLATE:
#if ($vlan_id !="")
#if ($interfaceName !="")
interface $interfaceName
switchport access vlan $vlan_id
switchport mode access
switchport port-security maximum 2
switchport port-security
switchport port-security aging time 1
switchport port-security violation restrict
switchport port-security aging type inactivity
ip arp inspection limit rate 100
no logging event link-status
ip dhcp snooping limit rate 100
#end
exit
#end
RUBY PUT:
RestClient.put "https://x.x.x.x/webacs/api/v1/op/cliTemplateConfiguration/deployTemplateThroughJob",
"{\"cliTemplateCommand\":
{\"targetDevices\":
{\"targetDevice\":
{\"targetDeviceID\":\"485830346\",
\"variableValues\":{\"variableValue\":[
{\"name\":\"interfaceName\",\"value\":\"GigabitEthernet1/0/17\"},
{\"name\":\"vlan_id\",\"value\":\"4\"}
]
}
}
},\"templateName\":\"vm_Student_Data\"
}
}",
"Accept"=>"application/json", "Accept-Encoding"=>"gzip, deflate", "Content-Length"=>"243", "Content-Type"=>"application/json"
RESPONSES:
{"mgmtResponse"=>
{"@responseType"=>"operation",
"@requestUrl"=>"https://x.x.x.x/webacs/api/v1/op/cliTemplateConfiguration/deployTemplateThroughJob",
"@rootUrl"=>"https://x.x.x.x/webacs/api/v1/op",
"cliTemplateCommandJobResult"=>{
"jobName"=>"JobCliTemplateDeployIOSDevices09_18_43_639_PM_07_03_2016",
"message"=>"An deploy job has been successfully created. "
}
}
}
"mgmtResponse": {
"@responseType": "operation",
"@requestUrl": "https://x.x.x.x/webacs/api/v1/op/jobService/runhistory?jobName=JobCliTemplateDeployIOSDevices11_16_16_707_PM_07_01_2016",
"@rootUrl": "https://x.x.x.x/webacs/api/v1/op",
"job": {
"description": "Cli Template Deploy for IOS devices",
"jobId": 627613049,
"jobName": "JobCliTemplateDeployIOSDevices11_16_16_707_PM_07_01_2016",
"jobStatus": "COMPLETED",
"jobType": "CliTemplateDeployIOSDevices",
"runInstances": {
"runInstance": {
"completionTime": "2016-07-01T23:16:49.190+08:00",
"lastStartTime": "2016-07-01T23:16:46.758+08:00",
"resultStatus": "FAILURE",
"results": {
"result": [
{
"property": 485830346,
"value": "Invalid var Values for given template's variables"
},
{
"property": "JobCliTemplateDeployIOSDevices11_16_16_707_PM_07_01_2016",
"value": "0/1 template configurations successfully applied."
}
]
},
"runId": 782951285,
"runStatus": "COMPLETED"
}
}
}
}
}
07-03-2016 11:54 PM
Hi Paul,
Can you post "vm_Student_Data" template contents for reference. Have you deployed this template already in prime??
Thanks,
Arun
07-04-2016 12:31 AM
Solved:
After testing everything else it was a typo in the 'targetDeviceID'. It's always the simple things.
07-04-2016 03:24 AM
Exactly Paul, Anyways, you solved it, that's great!!!
Regards,
Arun
02-28-2020 07:27 AM
Hi,
When my customer get API by GET ClientSessions, they got max 1000 data.
Is it a specification?
My customer has over 10,000 client sessions data.
They want to get all of client sessions data one time.
The following is the acquired API information :
https://<IP address>/webacs/api/v4/data/ClientSessions?.full=true&.maxResults=1000
https://d1nmyq4gcgsfi5.cloudfront.net/media/pi_3_7_devnet/api/v4/data/ClientSessions@_docs.html
02-28-2020 07:38 AM
Hi @younna,
Might be good to post this in its own question as is basically a slightly different topic.
Your client is encountering a common API concept called pagination.
You can see the maxRange in the query string you shared. Is common with REST APIs that you will have to do a little extra work to get all the data. its a good practice to get into because you never know how much you are going to get back!
When using either the query string or the HTTP header for paging, there is a limit of 1000 results per request. This limit can be configured.
03-02-2020 12:01 AM - edited 03-02-2020 12:03 AM
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide