REST API and JSON for CCNA: Query a Controller with GET and POST
REST APIs use HTTP to read and change resources and return structured data in JSON. In the CCNA you must recognize HTTP verbs, the parts of a URI, status codes and read a JSON object, without needing to program.

Edit this template Download .json
Learning objectives
- Match HTTP verbs to CRUD operations.
- Read key-value pairs, objects and arrays in a JSON.
- Recognize status codes 200, 201, 400, 401, 404 and 500.
Devices and addressing
| Device | Type | Details |
|---|---|---|
| Client | PC | Python / Postman requests.get() |
| Controller | svc | https://ctrl.ejemplo.local API REST · TLS 443 |
| SW-1 | Layer 3 switch | Managed Interfaces |
| R1 | Router | Managed OSPF |
Reference configuration (Cisco IOS)
Petición y respuesta
GET /api/v1/network-device HTTP/1.1
Host: ctrl.ejemplo.local
X-Auth-Token: eyJhbGciOi...
Accept: application/json
HTTP/1.1 200 OK
{
"response": [
{"hostname": "SW-1", "managementIpAddress": "10.0.0.2", "reachabilityStatus": "Reachable"},
{"hostname": "R1", "managementIpAddress": "10.0.0.1", "reachabilityStatus": "Reachable"}
],
"version": "1.0"
}
Python (requests)
import requests
r = requests.get("https://ctrl.ejemplo.local/api/v1/network-device",
headers={"X-Auth-Token": token}, verify=False)
for d in r.json()["response"]:
print(d["hostname"], d["managementIpAddress"])
Verification commands
curl -k -H "X-Auth-Token: <token>" https://ctrl.ejemplo.local/api/v1/network-deviceRevisar el código de estado HTTP (200, 401, 404)jq ".response[].hostname"
CCNA exam tips
CRUD ↔ HTTP: Create = POST, Read = GET, Update = PUT/PATCH, Delete = DELETE.
JSON: objects in braces {}, arrays in brackets [] and values in double quotes.
How to use this template
Press “Edit this template”: the editor opens with the topology loaded and ready to change (undo with Ctrl+Z). You can also copy the JSON and paste it into the editor with File ▸ Import JSON…. Then add devices, change IPs and export to PDF, PNG or SVG.
To practice, rebuild the topology in Cisco Packet Tracer, GNS3 or Cisco Modeling Labs and paste the reference configuration on each device. Addresses and names are examples: change them to create your own variants.
JSON template for the editor
This is the full diagram in JSON format. Paste it into the editor (File ▸ Import JSON…) or press the edit button to load it automatically.
Frequently asked questions
What does REST mean?
Representational State Transfer: an architecture style that uses HTTP to operate on resources identified by URI.
What is JSON?
A lightweight text format of key-value pairs, objects and arrays, readable by humans and machines.