Instiq
Chapter 5 · Infrastructure and Automation·v1.0.0·Updated 7/20/2026·~17 min

What's changed: Initial version

5.4Interpreting responses and models

Key points

Builds the ability to read RESTCONF/NETCONF responses (JSON/XML, <ok/>, rpc-reply), the underlying YANG data model (the container/list/leaf hierarchy), and the unified diff representing change (the @@ hunk, +/- lines), so you can judge "is this response success or failure," "what does this part of the model represent," and "what does this diff actually change."

In model-driven automation, what you exchange with a device is not human-oriented show output but a structured response (JSON/XML) and the model (YANG) that governs it. To judge whether automation "worked," you must read success/failure from the response shape, grasp what each part of the model represents, and read what a change diff actually changes. This section trains that reading skill as the interpretation of a given response, model, and diff, not memorization.

5.4.1Reading RESTCONF/NETCONF responses

  • RESTCONF maps CRUD to HTTP methods over HTTP (GET = read / POST = create / PUT = replace / PATCH = partial update / DELETE = delete). Responses are an HTTP status plus a JSON/XML body: 200 OK/201 Created are success, 204 No Content is success with no body, 401 is unauthenticated, 404 is a missing path (data), and 409 is a conflict. Read success/failure from both status and body.
  • NETCONF exchanges XML over SSH (usually port 830); success is <ok/> inside <rpc-reply> and failure is <rpc-error> (cause in <error-tag>). It separates datastores as candidate (for editing) -> commit -> running (live), finalized by <commit> after <edit-config>. Judge success/failure by whether the reply is <ok/> or <rpc-error>.
  • Read JSON response keys with their namespace: e.g., "ietf-interfaces:interface": [{ "name": "GigabitEthernet2", "enabled": true }] reads as "in the interface list of the ietf-interfaces model, there is an enabled entry named GigabitEthernet2." Calmly map which model, which element, what value.

5.4.2Reading the YANG model hierarchy

  • YANG is a language that describes the data model (structure definition) of device config/state. Its main constructs are a leaf holding one value, a leaf-list of same-kind leaves, a container grouping elements, and a list of repeated entries identified by a key (e.g., many interfaces). The actual XML/JSON data is an instance of this YANG hierarchy.
  • The knack for reading a model is to see "single or multiple?" and "what is the key?": list interface { key "name"; leaf enabled { type boolean; } } means "interface can occur multiple times keyed by name, and each has one boolean enabled." This structure appears in a response JSON as [...] (an array = list) or true/false (a boolean leaf).

5.4.3Reading a unified diff

  • A unified diff represents before/after change. The leading --- old / +++ new identifies which file's old/new, and the @@ -a,b +c,d @@ hunk header shows position ("old starts at line a for b lines, new at c for d lines"). The line prefixes are key: - = a removed line, + = an added line, (space) = context (unchanged).
  • Read a diff for its net change: - ip address 10.0.0.1 255.255.255.0 next to + ip address 10.0.0.2 255.255.255.0 means "the IP is changed from .1 to .2." Only + is an addition, only - is a deletion. In Git code review or a playbook diff, read whether this change is as intended and whether a dangerous deletion is mixed in.
Exam point

Most-tested: RESTCONF = HTTP methods <-> CRUD, success/failure from status plus JSON/XML (201 = created, 204 = success no body, 401 = unauthenticated, 404 = data not found); NETCONF = XML over SSH 830, <ok/> success / <rpc-error> failure, candidate -> commit -> running; YANG = structure definition of container/list(key)/leaf/leaf-list; unified diff = @@ hunk, - removed / + added / space is context. Practice reading meaning from the shape of responses, models, and diffs.

Suppose you are investigating a failed automation job. The job was supposed to enable an interface via RESTCONF, but downstream validation reports "the IF is still down." Looking first at the RESTCONF response, a PATCH /restconf/data/ietf-interfaces:interfaces/interface=GigabitEthernet2 returned HTTP/1.1 204 No Content. Jumping to "the body is empty, so it failed" is a mistake—204 is "success with no body," and the update itself was accepted. So where is the cause? Checking the diff (unified diff) you sent, the intent was "set enabled to true," but the actual payload was: - "enabled": true and + "enabled": false. That is, the net change is "enabled -> disabled," a content error swapping true and false. The response (204) is a success, but the content you sent was wrong—so the IF stays down; that is the correct isolation. Here YANG knowledge pays off: in ietf-interfaces, list interface { key "name"; leaf enabled { type boolean; } }, so enabled is a boolean leaf and should carry true (a boolean), not "true" (a string) or 1. Were this NETCONF, you would read success/failure not from an HTTP status like 204 but from <ok/> or <rpc-error> in the response XML, and confirm whether <commit> finalized candidate into running after <edit-config>. Being able to read this chain separately—communication success/failure from the response shape (204 = success), the content error from the diff (true -> false), and the value type from YANG (boolean leaf)—is the heart of model-driven troubleshooting.

ArtifactHow to read success/meaningCommon misreading
RESTCONF responseHTTP status plus body (201 created / 204 success no body / 401 / 404)Misreading 204 as "no body = failure"
NETCONF response`<ok/>` = success / `<rpc-error>` = failure, finalized by commitAssuming edit-config alone updates running
YANG modelStructure and type of container/list(key)/leaf/leaf-listPutting the string "true" into a boolean leaf
unified diffPosition via `@@`, net change from `-` removed / `+` addedConfusing the direction of `+`/`-`
Warning

Trap: "RESTCONF returned 204 No Content, so it failed because there is no body" is wrong—204 is success without a body, and the update was accepted (read success/failure from 2xx vs. 4xx/5xx). Also wrong: "NETCONF reflects into running with <edit-config> alone"—when using candidate, only <commit> finalizes it into running. A YANG boolean leaf should carry true/false (a boolean); the string "true" can be a type mismatch.

Reading RESTCONF/NETCONF responses, the YANG hierarchy, and unified diffs.
Reading comms success, content error, and type separately

5.4.4Section summary

  • RESTCONF maps HTTP methods to CRUD; read success from status plus body (201 created / 204 success no body / 401 / 404). NETCONF uses <ok/> success / <rpc-error> failure, candidate -> commit -> running
  • YANG defines the structure/type of container/list(key)/leaf/leaf-list, and the response JSON/XML is its instance; a boolean leaf takes a boolean
  • A unified diff reads position from the @@ hunk and net change from - removed / + added / space context. Isolate response success/failure, diff content, and model type separately

Sign in to track progress — Log in.

Quick check

(just a quick review)

Q1. A RESTCONF automation to enable an interface is reported failing with "the IF stays down." The response to `PATCH .../interface=GigabitEthernet2` was `HTTP/1.1 204 No Content`, and the sent diff was `- "enabled": true` / `+ "enabled": false`. Which isolation is most appropriate?

Q2. Over NETCONF you send `<edit-config>` to the device's candidate datastore and get `<ok/>` inside `<rpc-reply>`. Yet the running config shows the change not applied. What is the most appropriate next step?

Q3. Given this YANG excerpt: `list interface { key "name"; leaf name { type string; } leaf enabled { type boolean; } }`, which JSON payload sent via RESTCONF best conforms to the model?

Check your understandingPractice questions for Chapter 5: Infrastructure and Automation

Keep track of your progress

The full study guide is free to read. Sign up free to practice with the question bank, track what you have read, review your mistakes, and highlight passages.