+ 1

Would you shed some light on this Python/JSON question?

I am not able to make the print line to work beyond ["TABLE_intf"]. I'm trying to get the code to print the interface's information only (IP address, state (up or down), etc) from the attached JSON file. I'd appreciate any assistance, thanks. import requests import json url='http://xxx.cisco.com/ins' switchuser='xxx' switchpassword='xxx' myheaders={'content-type':'application/json'} payload={ "ins_api": { "version": "1.0", "type": "cli_show", "chunk": "0", "sid": "1", "input": "show ip interface brief", "output_format": "json" } } response = requests.post(url,data=json.dumps(payload), headers=myheaders,auth=(switchuser,switchpassword)).json() print(response["ins_api"]["outputs"]["output"]["body"]["TABLE_intf"])#["ROW_intf"]["prefix"]) I'll paste the JSON code in another post.. https://www.sololearn.com/discuss/2215491/?ref=app

27th Mar 2020, 5:20 AM
Jairo Arce Hernandez
Jairo Arce Hernandez - avatar
4 Respostas
+ 1
Code Crasher, this code is from a (Cisco) Nexus switch API. You might want to play around with some APIs and sandbox es at developer.cisci.com which are free and Postman, if this is interesting to you
27th Mar 2020, 6:09 AM
Jairo Arce Hernandez
Jairo Arce Hernandez - avatar
0
Thanks Mireille! I'll give it a try tomorrow
27th Mar 2020, 6:05 AM
Jairo Arce Hernandez
Jairo Arce Hernandez - avatar