02-23-2022 03:52 PM - last edited on 05-08-2023 11:02 AM by Paul Zimmerman
Hello Team, I was wanting to create guest SSID using RESTCONF interface on Cisco WLC 9800 Controller. I made use of yangsuite module that generates REST API and wrote a python script and the error message which I see upon execution (both attached).
Any thoughts why would it throw out that error when I clearly have list of dictionaries in the payload. TIA
03-03-2022 11:23 AM
Hello @dcasteli,
The images are really helpful but it would be even better if you could paste the Python code in here for us to debug using the code tab ( </> ) above. I have a Python linter extension on VS Code, so I normally paste any code with malformed bugs into there and it will highlight the syntax errors right away.
Let's break down this payload:
- the payload itself is a dictionary { }
- the payload dictionary has 9 main elements
- the first element in the dictionary has a list as its value and this list contains one dictionary with two sub-elements of its own.
As such,
payload["apf-vap-id-data"][0]["ssid"] = "guest-restconf"
payload["apf-vap-id-data"][0]["wlan-status"] = "True"
- (I believe you could technically remove the comma on line 17 also).
- So you see, there is not a 'list of dictionaries' but one list with two elements that serves as the value of the first element in the payload dictionary.
In order to work with a list, which the error is calling for, I think you would either need to call on the specific element which is a list, in your request:
data=json.dumps(payload["afp-vap-id-data"])
or
Place the brackets ( [ ] ) around everything in your payload and add some braces, making it a list of dictionaries: payload = { [ ] }
It gets tricky because you are not using RESTCONF or the other methods directly, as the guides describe:
Catalyst 9800 Programmability and Telemetry Deployment Guide
Cisco Catalyst 9800 Series Wireless Controller Programmability Guide
So, it's hard for me to say what the REST API you generated with YANG Suite is calling for.
Hope this helps!
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