cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
296
Views
5
Helpful
2
Replies
bbianco
Beginner

Newbie RESTCONF QUESTION. Addressing specific switch port problem.

 Apologies If I have posted this to the wrong group.

I am relatively new to DEVNET and am working on setting up some automation for my enterprise.

Because of the switch environment it is essential for me to get configuration info for a specific port.

 

I have built a query:

 

"https://x.x.x.15/restconf/data/Cisco-IOS-XE-native:native/interface/GigabitEthernet"

and get the following response:

 

{
    "Cisco-IOS-XE-native:GigabitEthernet": [
        {
            "name""0/0",
            "vrf": {
                "forwarding""Mgmt-vrf"
            },
            "Cisco-IOS-XE-ethernet:negotiation": {
                "auto"true
            }
        },
        {
            "name""1/0/1",
            "description""ZYXW",
            "switchport": {
                "Cisco-IOS-XE-switch:mode": {
                    "trunk": {}
                },
                "Cisco-IOS-XE-switch:trunk": {
                    "allowed": {
                        "vlan": {
                            "vlans""4,6,13,22,24"
                        }
                    }
                }
            }
        },
        {
            "name""1/0/10"
        },

... etc. (the rest isn't important, let it suffice to say that I see every GigabitEthernet port.)

The documentation that I read say that if I build the query to read:

 

https://x.x.x.15/restconf/data/Cisco-IOS-XE-native:native/interface/GigabitEthernet=1/0/1 


I should see just the 1/0/1 interface in the output. This does not happen, I get:

{
    "errors": {
        "error": [
            {
                "error-message""uri keypath not found",
                "error-tag""invalid-value",
                "error-type""application"
            }
        ]
    }
}
 
 
I have tried using quotes, and a number of other tricks to no avail. Keep in mind the query works just fine when look at an individual Vlan interface.
 
https://x.x.x.15/restconf/data/Cisco-IOS-XE-native:native/interface/Vlan=13
 
{
    "Cisco-IOS-XE-native:Vlan": {
        "name"13,
        "description""Management",
        "ip": {
            "address": {
                "primary": {
                    "address""x.x.x.15",
                    "mask""255.255.255.0"
                }
            }
        }
    }
}

 

Any thoughts as to what I am doing wrong?

 

Thanks and Be Well

 

 

2 REPLIES 2
matts1900-wb
Beginner

You have to take into account URL encoding. Replace the forward slashes in 1/0/1 with %2F, so that it reads 1%2F0%2F1. You will then get the output. This is why you get a result when using VLAN13, as there are no forward slashes in the request.

jack_kuppers
Beginner

Great question (was also my problem) and even better answer; this works in bash (eg with curl) and in Python (eg with requests). All examples are always with simple interface names, even here at DevNet, but in my network most interface names are like 1/0/10. This looks trivial, but it can be a headbreaker ...

So this was indeed the solution. Thanks !

Content for Community-Ad