06-19-2020 12:11 AM
Hi
Studying REST API and RESTCONF protocols for Cisco IOS XE I stumbled upon some examples using always-on Router ios-xe-mgmt.cisco.com. Where they use GET, POST operations with URL: https://ios-xe-mgmt.cisco.com:9443/restconf/data/ietf-interfaces:interfaces. I could build my own URL using GET https://ios-xe-mgmt.cisco.com:9443/restconf/data/Cisco-IOS-XE-native:native/ with a tool that builds an XML or JSON statement when you load it a .yang model.
This works fine for GET, but when I try to use POST it doesn't work.
I get this:
My question is: How can I figure it out which root, data store, yang module, container is valid for a Router or Switch?
Solved! Go to Solution.
06-20-2020 12:52 AM
Hi
uri is constructed based on how the yang model is structured.. tools like pyang and yang explorer help with the structure.
Have a look at this Cisco Live presentation slide 25 onwards
https://www.ciscolive.com/c/dam/r/ciscolive/apjc/docs/2016/pdf/DEVNET-1081.pdf
You can also look at the video for this session that should help with slides
Please hit the helpful button for any helpful posts
06-19-2020 11:40 AM
Hi
You get the device-specific models from Github
https://github.com/YangModels/yang/tree/master/vendor/cisco
hope this helps
06-19-2020 01:22 PM
06-20-2020 12:52 AM
Hi
uri is constructed based on how the yang model is structured.. tools like pyang and yang explorer help with the structure.
Have a look at this Cisco Live presentation slide 25 onwards
https://www.ciscolive.com/c/dam/r/ciscolive/apjc/docs/2016/pdf/DEVNET-1081.pdf
You can also look at the video for this session that should help with slides
Please hit the helpful button for any helpful posts
06-21-2020 01:14 AM
05-31-2021 05:11 PM
I know it's a bit late but I just ran into this as well and figured I'd post how I found the leafs, containers, etc.
I queried the capabilities off the C9200 I was testing on by using the following
https://10.0.0.2/restconf/data/netconf-state/capabilities
This returned various "URLs" with module names. For example I was looking for CDP
http://cisco.com/ns/yang/Cisco-IOS-XE-cdp?module=Cisco-IOS-XE-cdp&revision=2019-07-01 http://cisco.com/ns/yang/Cisco-IOS-XE-cdp-oper?module=Cisco-IOS-XE-cdp-oper&revision=2019-05-01
Knowing the Module name from the "URLs" above I went to https://yangcatalog.org/yang-search and searched for the module name Cisco-IOS-XE-cdp-oper. This will tell you how to append leafs, lists, etc to the URL, you can even click on the "Tree View" link inside the module column to see all the fields returned by the API along with an explanation of what they are.
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