• You can read Python data structures and you know the HTTP rules.
    Now you put them together against the kind of code you will see in an exam exhibit.

    Remember three RESTCONF principles:

    • HTTPS on TCP port 443

    • JSON format for data input and output

    • A long URL pointing to a specific configuration item on the router

    Network topology diagram of a Python workstation managing a Cisco router via RESTCONF API over HTTPS port 443.

    Figure 1 – Lab topology

    PC1 runs Python with the requests library installed.
    It reaches Cisco IOS-XE router R1 (192.168.1.1) over TCP port 443 to send RESTCONF traffic.

    Script 1 — Simple GET Request

    Here is the smallest networking script you can write.
    It asks R1 for its GigabitEthernet0/1 configuration over RESTCONF:

    import requests
    import urllib3
    urllib3.disable_warnings()
    
    url = "https://192.168.1.1/restconf/data/Cisco-IOS-XE-native:native/interface/GigabitEthernet=0%2F1"
    headers = {"Accept": "application/yang-data+json"}
    
    response = requests.get(url, headers=headers,
                            auth=("admin", "cisco123"),
                            verify=False)
    
    print(response.status_code)
    print(response.json())

    Walk through it line by line:

    • import requests: Loads the HTTP library.

    • urllib3.disable_warnings() and verify=False: Suppress SSL certificate warnings (acceptable in a lab, not in production).

    • url: Points at one specific item on the router (GigabitEthernet0/1).

    • headers: Tells R1 you want JSON, not XML.

    • requests.get(...): Sends an HTTPS GET request with your credentials.

    • auth=("admin", "cisco123"): Passes HTTP Basic Auth credentials to R1, exactly like an SSH login.

    • response.json(): Converts the JSON response body into a Python dict so you can print it.

    If R1 accepts the request, response.status_code returns 200 and the parsed dictionary appears.

    Answer the question below

    What HTTP method does this script use to read the interface configuration?

    Answer the question below

    What is the type of the value returned by response.json() in this script?

    Answer the question below

    Which HTTP status code would response.status_code show if R1 accepts the request?