QuestionQ66

VerifiedDevice-Level Network Automation

Drag and drop the code snippets into the boxes to construct a RESTCONF request that creates two access VLANs on a Cisco IOS XE device. Not all options are used.

Drag & Drop
base_url = "https://10.10.20.40:443/restconf/data/"
path_url = "Cisco-IOS-XE-native:native/vlan"
url = base_url + path_url
={
    "Cisco-IOS-XE-vlan:vlan-list": [
        {
            "id": 135,
            "name": "DATA"
        },
        {
            "id": 254,
            "name": "MGMT"
        }
    ]
}
headers = {
    'Accept': 'application/yang-data+json, application/yang-data.errors+json',
    'Content-Type': 'application/yang-data+json',
}
resp = requests.(url, =("admin", "Admin_1234!"),
    headers=headers,  = data, verify=False)
print(resp.status_code)
Explanation

Creating VLAN resources is an HTTP POST operation. The Requests library accepts HTTP Basic credentials through auth and sends a raw body through data; assigning the JSON object to data makes data=data the payload argument. patch would be used to modify an existing resource, while payload and xmlns are not Requests parameters in this call.

Community Discussion

No comments yet. Be the first to start the discussion!