06-15-2025 04:04 AM - edited 06-15-2025 04:04 AM
Hello, everyone.
I am studying RESTCONF for my ENCOR Exam and I have a question about how the URL is formatted.
I have the following code here:
import requests from rich import print as rprint headers = { "Accept": "application/yang-data+json" } url = "https://192.168.170.200:443/restconf/data/Cisco-IOS-XE-native:native/hostname" response = requests.get(url=url, headers=headers, auth=("admin", "cisco"), verify=False) rprint(response.json())
The URL is my cisco router running in Cisco CML. This code will return the hostname of the device
{'Cisco-IOS-XE-native:hostname': 'R1'}
I have a question about how the URL is formatted. The Cisco-IOS-XE-native is a YANG model that is used to interact/retrieve the running configuration of the device.
Inside the Cisco-IOS-XE-native YANG model, everything is stored inside the native object/container.
1. My first question is, why can't I just use a URL like this to retrieve the running configuration?
https://192.168.170.200:443/restconf/data/Cisco-IOS-XE-native
It only works if I do this:
https://192.168.170.200:443/restconf/data/Cisco-IOS-XE-native:native.
Is it always necessary to add in the container that stores everything?
2. If I want to retrieve something more specific like the version, the URL looks the following:
https://192.168.170.200:443/restconf/data/Cisco-IOS-XE-native:native/hostname
What's confusing me is what a double collon : and the forward slash / achieve. Why is there a double collon with :native but a forward slash with /hostname? When is which one used?
Thank you.
David
Solved! Go to Solution.
06-15-2025 05:10 AM
Hey @Mitrixsen the top level container is typically named after the module, or has a well known name like "native" here in XE. It fails does not work with Cisco-IOS-XE-native cos this is a module name (not a data node) restconf expects this to point to an actual data node (container, list, leaf etc…) you generally always need to specify the top level container after the module name.
The : separates the module name from the node name. Like you had native:native, this is when you need to qualify a node with its module namespace.
The / separates path components in the data hierarchy. So say native/hostname, this is inside the native container, and the leaf access of the host name. I recall this information this way:
Use the : when you need to specify which module a node comes from and use / to navigate through the hierarchy of containers/lists/leaves.
Hope this helps!
06-15-2025 05:10 AM
Hey @Mitrixsen the top level container is typically named after the module, or has a well known name like "native" here in XE. It fails does not work with Cisco-IOS-XE-native cos this is a module name (not a data node) restconf expects this to point to an actual data node (container, list, leaf etc…) you generally always need to specify the top level container after the module name.
The : separates the module name from the node name. Like you had native:native, this is when you need to qualify a node with its module namespace.
The / separates path components in the data hierarchy. So say native/hostname, this is inside the native container, and the leaf access of the host name. I recall this information this way:
Use the : when you need to specify which module a node comes from and use / to navigate through the hierarchy of containers/lists/leaves.
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