Week 9Network Assurance38 min

REST APIs and JSON Basics

Learning objectives

  • Read JSON structures used in network API responses
  • Explain REST verbs GET, POST, PUT, PATCH, DELETE
  • Understand authentication concepts for API access
  • Parse sample API output to answer operational questions

Watch first

Recommended video

JSON, XML & YAML (Day 60)

Video credit: Jeremy's IT Lab

Watch on YouTube
Recommended video

REST APIs (Day 61)

Video credit: Jeremy's IT Lab

Watch on YouTube

Also watch — playlist supplement

Recommended video

JSON (ENCOR 6.2) — CCNA automation context

Video credit: David Bombal

Watch on YouTube
Recommended video

REST APIs Part 1 (ENCOR 6.4)

Video credit: David Bombal

Watch on YouTube

Plain-English explanation

REST APIs expose network functions over HTTP/HTTPS using URLs (endpoints) and standard verbs. JSON is the most common data format — human-readable key/value pairs and arrays that scripts and controllers exchange.

Instead of show ip interface brief, an automation app might GET /interfaces and receive JSON listing each interface state — same data, machine-friendly.

Deep dive

HTTP verbs (CRUD mapping):

| Verb | Typical use | |------|-------------| | GET | Read data — safe, no change | | POST | Create resource | | PUT | Replace entire resource | | PATCH | Partial update | | DELETE | Remove resource |

JSON example:

{
  "hostname": "R1",
  "interfaces": [
    { "name": "Gi0/0", "ip": "10.1.1.1", "status": "up" },
    { "name": "Gi0/1", "ip": "10.2.1.1", "status": "down" }
  ]
}

XML/YAML (awareness): NETCONF often XML; Ansible playbooks YAML. CCNA expects JSON literacy first.

Auth: API tokens, OAuth, basic auth over HTTPS — never cleartext credentials on wire.

Step-by-step — read API response

Given JSON above:

  1. How many interfaces? → 2 (array length)
  2. Which is down? → Gi0/1
  3. Hostname? → R1

Practice in the automation sandbox tool — match keys to questions quickly.

POST example (conceptual): Create VLAN 30 via API body {"vlan-id": 30, "name": "GUEST"} — exact endpoint varies by platform.

Commands to know

curl — GET example (conceptual)

curl -k -H "Accept: application/json"
-H "Authorization: Bearer TOKEN"
https://203.0.113.1/restconf/data/ietf-interfaces:interfaces

Compare to CLI

show ip interface brief

Troubleshooting

| API issue | Check | |-----------|-------| | 401 Unauthorized | Token expired, wrong credentials | | 404 Not Found | Wrong endpoint path or API version | | 400 Bad Request | Malformed JSON body | | 415 Unsupported | Missing Content-Type: application/json |

Read response status code first — 2xx success, 4xx client error, 5xx server error.

Exam relevance

Exam trap

GET retrieves without modifying. Using GET to "change" config is wrong — use POST/PUT/PATCH per operation.

JSON syntax

Double quotes on keys/strings, commas between pairs, arrays in [ ], objects in { } — trailing comma invalid in strict JSON.

Practice checklist

  • Parse three sample JSON API responses without tools
  • Match HTTP verbs to create/read/update/delete scenarios
  • Use automation sandbox for REST scenario drills
  • Convert one CLI show output conceptually to JSON fields
  • Explain HTTPS importance for API credentials

Which HTTP method should retrieve device facts without changing configuration?

In JSON, which bracket type holds key-value pairs?

Video credits

These are free, open educational videos from independent creators. We link and embed them with attribution; all rights belong to the respective channels.

Related tools