PracticeLabs
Week 9Lesson 2Required27 min estimated0% progress

REST APIs and JSON Basics

Map the four HTTP verbs to CRUD, read an API response status line, and interpret a real JSON payload field by field so you can say what an automation call did and what it returned.

Lesson orientation

What you'll learn (4 objectives)~27 min: video → lesson → check → apply → lab prep

Learning objectives

  • Map HTTP GET, POST, PUT/PATCH, and DELETE to the CRUD operations
  • Interpret common HTTP status codes and locate the token used for authentication
  • Read a JSON object and array, including nested values, and name each data type
  • Spot the three JSON mistakes that break a payload — wrong quotes, trailing commas, wrong booleans

Terms you will see

RESTCRUDURIGET / POST / PUT / PATCH / DELETEStatus codeBearer tokenJSON objectJSON arrayBoolean

Time breakdown

  • Read the notes12 min
  • Read the worked JSON payload9 min
  • Find the invalid payloads6 min

Assigned video

Opens on YouTube
Recommended video

JSON, XML & YAML (Day 60)

By Jeremy's IT Lab · Opens externally on YouTube

Assigned watch
~6 min

Where to stop

JSON is the priority for this lesson; treat the YAML and XML portions as awareness.

The source marks this segment timestampStatus="unresolved" with no start or end, so no bounds are shown here.

The link opens in a new browser tab. Return here when you finish watching.

Watch for these concepts

  • The JSON rules — double quotes, colons, commas, lowercase booleans, no trailing comma
  • How YAML uses indentation and XML uses paired tags for the same data

Go beyond the video

The assigned video introduces the idea. CCNA Practice Labs completes the learning path: clarify core concepts, explore how each device behaves, visualize the communication path, check your understanding, and prepare for hands-on lab work.

Watch the concept → understand it → visualize it → practice it → apply it.

REST turns web requests into database-style operations

A REST API runs over HTTP. Each request names a resource with a URI — a path such as /api/v1/vlan — and carries a verb saying what to do to it. Those verbs map cleanly onto the four CRUD operations, the four things you can do to any stored record.

Verbs to CRUD
CRUDHTTP verbWhat it doesChanges state?
CreatePOSTAdd a new resource — a VLAN, a userYes
ReadGETRetrieve current stateNo
UpdatePUT / PATCHModify an existing resourceYes
DeleteDELETERemove a resourceYes
GET is the only safe one
POST, PUT, and DELETE all change something; GET only retrieves. That single distinction is a frequent exam target, and it is also the practical one — a GET against a production controller is something you can run without a change window, and the other three are not.
Status codes — and the families behind them
CodeMeaningFamily rule
200 OKRequest understood and succeeded2xx — success
201 CreatedA POST created the new resource2xx — success
401 UnauthorizedAuthentication failed or was missing4xx — the client got it wrong
404 Not FoundThe resource path does not exist4xx — the client got it wrong

The family rule is worth more than the individual codes: 2xx means success, 4xx means you the client got something wrong, 5xx means the server failed. That lets you triage an unfamiliar code correctly — a 403 you have never seen is still your problem, and a 502 still is not.

Four requests, four CRUD operations
GET    https://controller/api/v1/vlan            ! Read every VLAN
POST   https://controller/api/v1/vlan            ! Create a new VLAN (body describes it)
PUT    https://controller/api/v1/vlan/50         ! Update VLAN 50
DELETE https://controller/api/v1/vlan/50         ! Delete VLAN 50

! Requests that change or read protected data carry a header:
!   Authorization: Bearer <token>
!   Content-Type: application/json

The path after the host names the resource; the verb in front names the action. Same URL, different verb, different effect — that is the whole shape of a REST call. Authentication rides in a header, typically Authorization: Bearer <token>, obtained by first logging in. Passwords never go in the URL.

Reading a JSON payload field by field

A GET to /api/v1/interface/GigabitEthernet0-1 returns the payload below. Read it top to bottom rather than skimming for the value you want — the structure is what the exam asks about.

One interface, as JSON
{
  "interface": "GigabitEthernet0/1",
  "admin_state": "up",
  "line_protocol": "up",
  "ipv4": {
    "address": "192.0.2.5",
    "prefix_length": 30
  },
  "description": "uplink-to-core",
  "counters": {
    "input_errors": 0,
    "crc": 0
  },
  "routing_enabled": true
}
  • The outermost braces are one object — an unordered set of key/value pairs describing a single interface.
  • "interface": "GigabitEthernet0/1" is a string value; both key and value sit in double quotes with a colon joining them.
  • admin_state and line_protocol are the two halves of the familiar show ip interface brief status, here as separate string fields.
  • ipv4 holds a nested object — the value of one key is itself another set of pairs. Nesting is how JSON expresses "the IPv4 details of this interface".
  • prefix_length: 30 is a number, so it is unquoted. 192.0.2.5 is quoted because it is a string; 30 is not.
  • routing_enabled: true is a boolean — lowercase and unquoted. true, false, and null are never quoted and never capitalised.
  • No comma follows the last pair. A comma there would make the whole payload invalid.
Troubleshooting — the three faults that break a payload
Compare { "vlan_id": 10, "name": "SALES" } with { 'vlan_id': 20, 'name': 'ENG' } and { "vlan_id": 30, "name": "GUEST", }. The first is valid. The second breaks the double-quote rule — JSON keys and string values must use double quotes, never single. The third breaks the trailing-comma rule: the comma after the final pair is not allowed. Those two, plus capitalised or quoted booleans (True or "true" instead of true), are the faults CCNA questions plant most often, and all three are invisible at a glance because the data itself looks perfectly sensible.

If the controller returned many interfaces rather than one, a JSON array — square brackets — would hold the list, with a comma between each interface object. Arrays preserve order; objects do not. And there is still no trailing comma after the last object inside the array.

What you should retain

  • Verbs to CRUD: POST creates, GET reads, PUT and PATCH update, DELETE deletes.
  • GET is read-only and never changes device state.
  • Status codes: 200 OK, 201 Created, 401 Unauthorized, 404 Not Found — 2xx success, 4xx client, 5xx server.
  • Authentication is a token or API key in a header, never a password in the URL.
  • JSON rules: double quotes on keys and strings, colon between key and value, comma between pairs, lowercase true/false/null, numbers unquoted, no trailing comma.
  • Objects use braces and are unordered; arrays use square brackets and preserve order.
Pause and predictNot scored — nothing is recorded

Before you read on

(1) You send a request that reads the current VLAN list and get back 200 — which verb did you almost certainly use, and did it change anything? (2) Of these three, which is valid JSON, and what single rule does each invalid one break? A: { "vlan_id": 10, "name": "SALES" } B: { 'vlan_id': 20, 'name': 'ENG' } C: { "vlan_id": 30, "name": "GUEST", }

Interactive tool
Required~9 min

Automation Sandbox

Drill REST-verb and JSON-validity items until the rules are automatic — the syntax faults are the kind you only spot reliably after seeing several dozen of them.

Section quiz

Check this section before moving on

Required8 questions~10 min

Automation & APIs

The quiz opens on its own page so you can focus on it. It is a Week 1 milestone, tracked separately from this lesson's own completion.

Topics covered

  • Configuration drift and intended state
  • What a controller centralises and what it does not
  • The three planes
  • Verbs to CRUD and status codes
  • JSON syntax and structure
Start the quiz

Study deeper

Topic guides extend this lesson — they do not replace the first-party walkthrough above.

Automation & APIs

For REST's wider characteristics — client/server, stateless, cacheable