In the previous lesson, you configured a router with NETCONF over SSH (port 830) using XML and the ncclient Python library.
RESTCONF (RFC 8040) accesses the same YANG data models over HTTPS (port 443), using JSON or XML.
Figure 1 – NETCONF vs RESTCONF
Because RESTCONF uses standard HTTPS, you do not need a specialized protocol library like ncclient.
You can send requests with any HTTP client, including Python requests, curl, or Postman.Key Differences
RESTCONF is stateless: there is no persistent session, no hello exchange, and no capabilities negotiation.
Each HTTP request is self-contained and includes authentication and formatting headers.Unlike NETCONF, RESTCONF has no candidate datastore, no lock, and no commit operation.
Every write request modifies the running configuration immediately.Feature
NETCONF
RESTCONF
Transport
SSH (TCP 830)
HTTPS (TCP 443)
Data encoding
XML
JSON or XML
Data models
YANG
YANG (same models)
Session
Stateful (hello, session-id)
Stateless (no session)
Candidate datastore
Yes (lock, commit)
No (running only)
Python library
ncclient
requests (or any HTTP client)
Table 1 – NETCONF vs RESTCONF
Answer the question below
What transport protocol does RESTCONF use instead of SSH?
RESTCONF maps YANG data nodes directly to HTTP URLs.
You read or change a setting by sending an HTTP request to the URL that represents that specific YANG resource.RESTCONF URI Structure
Every RESTCONF request targets a structured URI divided into three parts:

Figure 2 – RESTCONF URI structure
Protocol and host (https://192.168.1.1) identify the management IP of your device.
API root (/restconf/data) tells the device you want to read or modify configuration and operational data.
YANG resource path (Cisco-IOS-XE-native:native/interface/GigabitEthernet=1) points to the YANG module, container, list, and key (module:container/list/key=value).
HTTP Methods
RESTCONF uses five standard HTTP methods, each mapped to an equivalent NETCONF operation:
HTTP method
CRUD
NETCONF equivalent
GET
Read
<get-config>POST
Create
<edit-config>(operation="create")PUT
Replace
<edit-config>(operation="replace")PATCH
Update
<edit-config>(operation="merge")DELETE
Delete
<edit-config>(operation="delete")Table 2 – HTTP methods mapped to NETCONF operations
To read GigabitEthernet1, send a GET to /restconf/data/.../GigabitEthernet=1.
To update its description without touching its IP address, send a PATCH to that same URI with the new value in the JSON body.Answer the question below
Which HTTP method is the RESTCONF equivalent of the NETCONF get-config operation?
Request and Response
When sending a GET request, include an Accept header to specify the encoding format you want back:

Figure 3 – GET request
Accept: application/yang-data+json tells R1 to return JSON (use application/yang-data+xml for XML).
R1 replies with an HTTP status code and the requested YANG data in JSON:
Figure 4 – GET response with JSON data
Answer the question below
What HTTP header tells the device to return data in JSON format?
Answer the question below
Rewritten for RESTCONF, how many HTTP requests does a lock, get-config, edit-config, commit, unlock script need?
In this lab, you enable RESTCONF on R1 and run Python scripts from your management workstation to read and update an interface.

Figure 5 – Lab topology
R1 (192.168.1.1) is a Cisco IOS-XE router with a local admin account already configured.
Workstation (192.168.1.10) runs Python with the requests library installed and connects to R1 over HTTPS on port 443.
Enabling RESTCONF on IOS-XE
On IOS-XE, RESTCONF needs the RESTCONF agent, the HTTPS server, and local authentication.
Enable all three in global configuration mode:R1# conf t Enter configuration commands, one per line. End with CNTL/Z. R1(config)# restconf R1(config)# ip http secure-server R1(config)# ip http authentication local R1(config)# endrestconf starts the RESTCONF agent, ip http secure-server enables HTTPS on TCP port 443, and ip http authentication local authenticates API requests against local user accounts.
Verifying RESTCONF
Confirm that RESTCONF is active in the running configuration:
R1# show run | include restconf restconfVerify that the HTTPS server is listening on port 443:
R1# show ip http server status HTTP server status: Disabled HTTP server port: 80 HTTP server authentication method: local HTTP secure server status: Enabled HTTP secure server port: 443Answer the question below
What IOS-XE command enables the RESTCONF agent on your router?
Reading Configuration with Python
Run this script on your workstation to retrieve the GigabitEthernet1 configuration:
import requests import urllib3 urllib3.disable_warnings() url = "https://192.168.1.1/restconf/data/Cisco-IOS-XE-native:native/interface/GigabitEthernet=1" headers = { "Accept": "application/yang-data+json" } response = requests.get( url, headers=headers, auth=("admin", "cisco123"), verify=False ) print(response.status_code) print(response.json())url targets GigabitEthernet=1 inside the Cisco-IOS-XE-native YANG model.
headers requests the response body in YANG-modeled JSON.
auth sends your username and password using HTTP Basic authentication.
verify=False skips TLS certificate checks for self-signed lab certificates (always verify certificates in production).
When the request succeeds, Python prints 200 followed by the JSON configuration of GigabitEthernet1.
Answer the question below
What Python library is used to send HTTP requests to RESTCONF?
Pushing Configuration with Python
Now send a PATCH request to the same interface URI to update its description:

Figure 6 – PATCH request
import requests import urllib3 urllib3.disable_warnings() url = "https://192.168.1.1/restconf/data/Cisco-IOS-XE-native:native/interface/GigabitEthernet=1" headers = { "Content-Type": "application/yang-data+json", "Accept": "application/yang-data+json" } payload = { "Cisco-IOS-XE-native:GigabitEthernet": [ { "name": "1", "description": "Configured via RESTCONF" } ] } response = requests.patch( url, headers=headers, auth=("admin", "cisco123"), json=payload, verify=False ) print(response.status_code)Include Content-Type: application/yang-data+json so R1 knows the request body uses YANG JSON.
Notice that GigabitEthernet is enclosed in square brackets [ ] because it is defined as a YANG list in the native model.When R1 applies the change, it returns 204 No Content:

Figure 7 – PATCH response
Status 204 confirms the change was applied and returns an empty body.
Verify the new description on R1:
R1# show run interface GigabitEthernet1 Building configuration... Current configuration : 98 bytes ! interface GigabitEthernet1 description Configured via RESTCONF ip address 192.168.1.1 255.255.255.0 endAnswer the question below
What HTTP status code does a successful PATCH return in RESTCONF?