cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1555
Views
5
Helpful
5
Replies
carlovalle.25
Beginner

How to build my own URL for RESTCONF

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:

 

Screen Shot 2017-10-10 at 9.34.40 AM.png

Screen Shot 2017-10-10 at 9.34.45 AM.png

My question is: How can I figure it out which root, data store, yang module, container is valid for a Router or Switch?

1 ACCEPTED SOLUTION

Accepted Solutions

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

https://www.ciscolive.com/global/on-demand-library.html?search=devnet-1081#/video/1533848237997001D3mq

 

Please hit the helpful button for any helpful posts

View solution in original post

5 REPLIES 5
omz
VIP Collaborator VIP Collaborator
VIP Collaborator

Hi

You get the device-specific models from Github 

https://github.com/YangModels/yang/tree/master/vendor/cisco

hope this helps

 

Thank you for help.

I got the model but how can I build my URI based on the model that I download?

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

https://www.ciscolive.com/global/on-demand-library.html?search=devnet-1081#/video/1533848237997001D3mq

 

Please hit the helpful button for any helpful posts

View solution in original post

I am going to try PYANG. It sounds better. Thank you!!
injector22
Beginner

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.

Content for Community-Ad