cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
344
Views
0
Helpful
1
Replies

DNA API error running a template

glsparks
Level 1
Level 1

I'm attempting to follow this in a lab environment. DNA 2.2.3.5

Cisco DNA Center Network Automation with Template Programmer API – Part 1 - Cisco Blogs

I have python 3.10 and the dna api installed and can see all my templates in DNA center.

As per the example I have created this simple velocity template:

interface ${interface}

switchport access vlan ${vlan}

However when attempting to run the following with Python 3.10:

python template.py --template Testing/TEST --device 192.168.1.10 --params '{"vlan":"120","interface":"gig1/0/1"}'

I get the following error:

Executing template on:192.168.1.10, with Params:'{vlan:10,interface:gig1/0/1}'
Traceback (most recent call last):
File "D:\Templates\template.py", line 244, in <module>
response = execute(id, params, bindings, args.device, inputParams, args.force)
File "D:\Templates\template.py", line 62, in execute
"params": json.loads(params)
File "C:\Program Files\Python310\lib\json\__init__.py", line 346, in loads
return _default_decoder.decode(s)
File "C:\Program Files\Python310\lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:\Program Files\Python310\lib\json\decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Can anyone help with this one? Is it the velocity template? Or is it the syntax of the command? Is it Python version? Or DNA?

Thanks

 

1 Reply 1

Dan Rowe
Cisco Employee
Cisco Employee

It looks like the python script you are running may have some lines hard coded as you can see you are using the following syntax in as the parameter when executing the script:

--params '{"vlan":"120","interface":"gig1/0/1"}'

But the error you mentioned shows a different syntax for that parameter being used:

Executing template on:192.168.1.10, with Params:'{vlan:10,interface:gig1/0/1}'

Can you share the code you have in template.py please?

Review Cisco Networking for a $25 gift card