skip to content

RESTCONF

The same YANG-modelled data as NETCONF, exposed as ordinary HTTP resources with JSON or XML bodies. It is what teams reach for when they want to drive a device from everyday tooling.

on this pageshow

explore

questions

28

On a RESTCONF server, what does each HTTP method — GET, POST, PUT, PATCH and DELETE — do to YANG-modelled configuration data?

level: juniorimportance: must knowfreq 22%

answer

  1. one verb per CRUD job
  2. each verb has a NETCONF twin
  3. replace versus merge
  4. POST names the parent, not the child
  5. delete, not remove

basics

~20 s

RESTCONF (RFC 8040) maps HTTP methods onto YANG data: GET reads a subtree, POST creates a child or invokes an operation, PUT creates or replaces the target, plain PATCH merges into it, and DELETE removes an existing node.

solid answer

~40 s

RFC 8040 §4 ties each method to a NETCONF equivalent. `GET` (and `HEAD`) is `<get-config>`/`<get>` and returns the target node with all its descendants. `POST` on the datastore or a data resource creates one child inside it — `201 Created` with a `Location` header, `409 Conflict` if the child already exists — while `POST` on an operation resource runs the operation. `PUT` is an `<edit-config>` create-or-replace of the node it names (`201` when it creates, `204` when it replaces) and a `<copy-config>` when aimed at `/data` itself. Plain `PATCH` is a `merge`: it adds or updates children but cannot delete them, and it never creates the target. `DELETE` is NETCONF `delete`, not `remove`, so the node must already exist.

go deeper

for a junior

Recall the five verbs and what each does to a YANG subtree: GET reads, POST creates under a parent, PUT replaces, plain PATCH merges, DELETE removes an existing node.

for a middle

Explain the NETCONF operation behind each method and the status codes that prove it: 201 with Location for POST, 201 versus 204 for PUT, 409 for a duplicate create.

for a senior

Show you know which method an automation job should use for a partial change, and why a PUT on a parent node is the dangerous default.

for a principal

Discuss how one method-to-operation mapping keeps RESTCONF and NETCONF edits consistent on a device, and when a team should mandate merge-style edits.

## What RESTCONF does with HTTP **RESTCONF** (RFC 8040, Standards Track, January 2017) exposes a network device's configuration and state data — data whose shape is defined by **YANG** modules — as HTTP resources. Every YANG container, list entry, leaf, leaf-list entry, anydata and anyxml node under `{+restconf}/data` is a **data resource** with its own URI; `{+restconf}/data` itself is the **datastore resource**; every YANG `rpc` is an **operation resource** under `{+restconf}/operations`. RFC 8040 §4 then gives each HTTP method one job on those resources and ties that job to a NETCONF operation, so a device that speaks both protocols treats a change the same way whichever protocol carried it. Two rules frame everything that follows: - **A method acts on the whole subtree.** RFC 8040 §3.5 says a method on a data resource affects the targeted node *and all of its descendants*. Reading a container returns everything inside it; replacing a container replaces everything inside it. - **The server owns the transaction.** The client sends no lock and no commit. Transaction management is the server's, and each successful edit is saved to non-volatile storage if the device has it. ## The method table | Method | Target | NETCONF equivalent | Success | Watch out for | |---|---|---|---|---| | `GET`, `HEAD` | datastore or data resource | `<get-config>`, `<get>` | `200 OK` | `404` for a missing instance; `405` on an operation resource | | `POST` | datastore or data resource (the parent) | `<edit-config>` with `create` | `201 Created` + `Location` | `409 Conflict` if the child exists | | `POST` | operation resource | the `rpc` itself | `200 OK` with output, `204` without | it is not a data write at all | | `PUT` | data resource | `<edit-config>` create or replace | `201` if created, `204` if replaced | omitted children are deleted | | `PUT` | datastore resource | `<copy-config>` | as for any `PUT` | the whole datastore is replaced | | `PATCH` (plain) | existing datastore or data resource | `<edit-config>` `merge` | `200` with a body, `204` without | the target is never created | | `DELETE` | one data resource instance | `<edit-config>` `delete` | `204 No Content` | fails if the node does not exist | ## Reading: GET and HEAD `GET` returns the target node with its descendants, filtered by access control: content the user may not read is left out of the response. A request for a list instance that does not exist gets `404 Not Found`; a `GET` on an operation resource gets `405 Method Not Allowed`, because an `rpc` is invoked, not read. `HEAD` returns the same header fields — including any `ETag` and `Last-Modified` the server keeps — without the body. ## Writing: POST, PUT and PATCH 1. **`POST` creates.** The URI names the *parent*; the body carries exactly one child instance, key values included. Success is `201 Created` with a `Location` header naming the new child and no body. If the child already exists the request fails with `409 Conflict`, so `POST` is create-only. A `POST` to an operation resource is its other mode: it invokes the operation. 2. **`PUT` creates or replaces.** The URI names the resource itself. If it did not exist it is created (`201`); if it did, its whole subtree is replaced by the body (`204`), and children the body leaves out are gone afterwards. A `PUT` to `{+restconf}/data` replaces the entire datastore. A `PUT` may not change a list entry's keys: the key values in the body must match those in the URI. 3. **Plain `PATCH` merges.** The body — `application/yang-data+json` or `application/yang-data+xml` — is merged into the target: missing children are created, present ones updated, unmentioned ones left alone. It cannot delete a child, and if the target itself does not exist the server must not create it. Richer patch formats such as **YANG Patch** (RFC 8072) are optional; a server lists the ones it accepts in the `Accept-Patch` header of its `OPTIONS` response. ## Removing: DELETE `DELETE` maps to NETCONF `delete`, not `remove`: RFC 8040 says the resource must exist or the method fails, where `remove` would have ignored a missing node. A `DELETE` also removes exactly one instance — aimed at a list or leaf-list, it must identify a single entry. Success is `204 No Content`. ## What every method shares - The server converts the URI into a YANG instance identifier and applies **NACM** (RFC 8341, which obsoletes RFC 6536) to it. A refused write normally returns `403 Forbidden` with error-tag `access-denied`; a server may answer `404` instead. - Errors come back as an `errors` structure carrying NETCONF-style fields such as `error-type`, `error-tag` and `error-message`. - `OPTIONS` is mandatory and tells the client which methods a resource supports. The version a candidate should be able to say without notes: **GET reads, POST creates under a parent or runs an operation, PUT replaces what it names, plain PATCH merges into what it names, and DELETE removes one thing that must already exist.**

  • Why does RESTCONF offer both POST and PUT for creating data?
    They differ in who names the resource and what happens on a repeat. `POST` targets the parent, carries the new child (keys included) in the body, and fails with `409 Conflict` if that child exists — a strict create. `PUT` targets the new resource's own URI and creates or replaces it, so repeating it converges on the same state. Use `POST` when a duplicate must be an error, `PUT` for an idempotent upsert of a node you fully describe.
  • How does a RESTCONF client discover which PATCH formats a server accepts?
    It sends `OPTIONS` to the resource. RFC 8040 requires the server to return an `Accept-Patch` header listing the patch media types: plain patch uses `application/yang-data+json` or `application/yang-data+xml`, and a server that supports YANG Patch (RFC 8072) also lists `application/yang-patch+json` or `+xml` and advertises the `:yang-patch` capability in its monitoring data.

saying these in an interview costs you the question

  • PUT and PATCH both just update the fields you send.
  • A RESTCONF DELETE of a missing node quietly succeeds, like NETCONF remove.
  • To create a list entry with POST, send it to the new entry's own URI.
  • A plain PATCH creates the target resource if it does not exist yet.
  • A plain PATCH can delete a child by sending it with an empty value.
open as a page

In RESTCONF, what does each child of the API root resource — data, operations and yang-library-version — give a client?

level: juniorimportance: must knowfreq 16%

basics

~20 s

Under the RESTCONF API root, data is the one combined datastore of configuration and state that clients read and edit, operations lists and invokes the server's YANG RPCs, and yang-library-version gives the ietf-yang-library revision the server implements.

open as a page

How does RESTCONF differ from NETCONF in transport, message encoding and the way a client converses with a device?

level: juniorimportance: must knowfreq 24%

basics

~20 s

RESTCONF carries YANG-modelled data over HTTPS as XML or JSON, one self-contained HTTP request per operation. NETCONF sends XML RPCs over a long-lived SSH or TLS session, which can hold locks and stage edits before committing them.

open as a page

In RESTCONF, how do YANG containers, lists and leaves become the URI path of a data resource under {+restconf}/data?

level: juniorimportance: must knowfreq 20%

basics

~20 s

Every data node from the top of the YANG tree down to the target becomes one path segment under {+restconf}/data: containers and leaves by name, list entries as name=key, and the top-level node prefixed with its module name.

open as a page

Why does a RESTCONF server reject a JSON body whose member names are unqualified, and where does RFC 7951 require module prefixes?

level: middleimportance: must knowfreq 18%

basics

~20 s

RFC 7951 requires every top-level JSON member to be named module:node, and a child to be qualified again only when its module differs from its parent's, as with augmented nodes; without those names the server cannot map the body to its schema.

open as a page

A RESTCONF dashboard pulls 40 MB of interface data to show one counter per interface; what do depth and fields each cut?

level: middleimportance: must knowfreq 16%

basics

~20 s

RESTCONF's depth prunes by level: counting the target as level 1, nodes deeper than level N are dropped, whatever their names. fields prunes by name: fields=interface(name;statistics/in-octets) returns just those nodes for every entry. Both are optional, advertised capabilities.

open as a page

What RESTCONF URI targets the IPv4 MTU of interface eth0/1 in ietf-interfaces augmented by ietf-ip, and why is each segment written that way?

level: middleimportance: must knowfreq 15%

basics

~10 s

{+restconf}/data/ietf-interfaces:interfaces/interface=eth0%2F1/ietf-ip:ipv4/mtu: the module name on the top node, the key's slash percent-encoded, and ietf-ip: again on ipv4 because the ietf-ip augmentation defines that container.

open as a page

An automation job used a RESTCONF PUT to change one interface's description, and the interface's other settings vanished; what happened, and what should it have sent?

level: seniorimportance: must knowfreq 15%

basics

~20 s

PUT replaces the whole target resource with the body, so every configured child the body omitted was deleted or reverted to its YANG default. The job should have sent a plain PATCH (a merge) or a PUT aimed at the description leaf.

open as a page

A RESTCONF server shares a device with NETCONF offering :candidate but not :writable-running; what happens to the datastores when a RESTCONF PATCH to /data succeeds?

level: seniorimportance: must knowfreq 11%

basics

~20 s

The PATCH edits the candidate, and the RESTCONF server must commit the candidate to running immediately after the edit — taking any other client's uncommitted candidate edits live with it — and, if the device has :startup, also update startup.

open as a page

A nightly job changes VLANs, interfaces and routing on one device; what atomicity does NETCONF give it that separate RESTCONF requests do not?

level: seniorimportance: must knowfreq 14%

basics

~20 s

NETCONF lets the job lock the device, build every edit in the candidate, validate, and commit it all at once; if any part fails, running stays unchanged. Separate RESTCONF requests each stand alone, so a failure midway leaves earlier edits applied.

open as a page

Which media types carry YANG data in RESTCONF, and how do the Accept and Content-Type headers decide the encoding?

level: juniorimportance: should knowfreq 14%

basics

~20 s

RESTCONF carries YANG data as application/yang-data+json (RFC 7951 rules) or application/yang-data+xml. Content-Type names the encoding of the body sent, Accept the encoding wanted back; an unsupported input format earns 415, an unacceptable output format 406.

open as a page

What does the RESTCONF content query parameter select, and what does a GET return when the parameter is left out?

level: juniorimportance: should knowfreq 12%

basics

~20 s

RESTCONF's content parameter chooses which descendants a GET returns: config (configuration only), nonconfig (state only) or all. Left out, it defaults to all, so the reply mixes settings and live state. Every server must support it.

open as a page

A RESTCONF POST either creates data or invokes an operation; how does the server tell which, and what does each mode return?

level: middleimportance: should knowfreq 10%

basics

~20 s

The target resource decides. POST to the datastore or a data resource creates one child (201 Created plus Location; 409 if it exists); POST to an rpc under /operations or an action under /data invokes it (200 with output, 204 without).

open as a page

A RESTCONF client hard-codes /restconf and gets 404 from a device whose API lives elsewhere; how should it find the API root?

level: middleimportance: should knowfreq 11%

basics

~10 s

A RESTCONF client must not assume /restconf: it sends GET /.well-known/host-meta, takes the single Link whose rel is restconf from the XRD reply, and prefixes that href to every later request, such as href/data.

open as a page

Why does RFC 7951 encode a YANG uint64 counter as a JSON string, and an empty-type leaf as [null], in RESTCONF bodies?

level: middleimportance: should knowfreq 10%

basics

~20 s

Many JSON parsers store numbers as IEEE 754 doubles, exact only up to 2^53, so int64, uint64 and decimal64 travel as strings; and many treat a null member as missing, so an empty leaf is the one-element array [null].

open as a page

A RESTCONF POST adds a permit entry to an ordered-by-user ACL after its deny-all entry; how do insert and point fix the order?

level: middleimportance: should knowfreq 8%

basics

~20 s

RESTCONF's insert parameter defaults to last, so the new entry landed behind deny-all and never matches. insert=before with point set to the deny-all entry's path places it ahead; both work only on POST and PUT into ordered-by-user lists or leaf-lists.

open as a page

In a RESTCONF URI, how are multi-key list entries, key values containing reserved characters, and leaf-list entries encoded?

level: middleimportance: should knowfreq 9%

basics

~20 s

A list entry is one segment: the list name, '=', then every key value in key-statement order separated by commas; a leaf-list entry is name=value. Values use their type's canonical form, with reserved characters, commas included, percent-encoded.

open as a page

Which RESTCONF resources carry an ETag and Last-Modified, what updates them, and what can a client safely conclude from them?

level: seniorimportance: should knowfreq 8%

basics

~20 s

The datastore resource must carry an ETag and should carry Last-Modified; configuration data resources should carry an ETag and may carry Last-Modified, otherwise reusing the datastore's. Only configuration changes update them — on the node, its ancestors and the datastore.

open as a page

On an NMDA RESTCONF server, why read /ds/ietf-datastores:operational instead of /data to check whether a configured interface setting is actually in use?

level: seniorimportance: should knowfreq 7%

basics

~10 s

RESTCONF's /data is RFC 8040's combined view, whose configuration nodes show what was configured; RFC 8527's /ds/ietf-datastores:operational returns only values the system is actually using, and with-origin can say where each came from.

open as a page

A RESTCONF JSON body sets the ietf-interfaces type leaf to plain ethernetCsmacd and is rejected; how must RFC 7951 encode identityref values?

level: seniorimportance: should knowfreq 7%

basics

~20 s

An identityref value is a string naming the identity, qualified module:identity with the defining module's name whenever the identity lives in a different module from the leaf, so ietf-interfaces' type takes "iana-if-type:ethernetCsmacd", not the bare name or an XML prefix.

open as a page

After a router upgrade, a RESTCONF backup job shows enabled=true vanishing from every interface; what changed, and how does with-defaults make the export deterministic?

level: seniorimportance: should knowfreq 9%

basics

~10 s

The server's advertised basic-mode changed, typically to trim, which omits leaves equal to their YANG default; enabled is still true. with-defaults=report-all returns every node regardless of basic-mode; report-all-tagged also marks the defaults.

open as a page

A script builds RESTCONF URIs by copying YANG schema paths and tree diagrams, and requests fail; which schema-path habits produce wrong data resource URIs?

level: seniorimportance: should knowfreq 6%

basics

~20 s

Schema paths carry what a RESTCONF data path must not: import prefixes in place of module names, choice and case nodes absent from the data tree, and XPath predicates in place of name=key. Augmented nodes need their module name; grouping contents do not.

open as a page

Would you build a one-VLAN self-service portal and a nightly network-wide change window on RESTCONF, NETCONF or both, and why?

level: principalimportance: should knowfreq 9%

basics

~20 s

RESTCONF fits the portal: small independent edits from web tooling, with entity-tag checks. NETCONF fits the window: locks, candidate, validate and confirmed commit per device. Neither makes a multi-device change atomic; the orchestrator owns that.

open as a page

How does a client invoke a YANG rpc or a YANG action over RESTCONF, compared with the same call over NETCONF?

level: middleimportance: nice to knowfreq 8%

basics

~20 s

RESTCONF invokes an rpc with POST to {+restconf}/operations/module:name, and an action with POST to its data node's URL plus the action name. NETCONF puts the rpc element inside <rpc>, or an <action> element carrying the node's full path and keys.

open as a page

When does a RESTCONF client need a YANG Patch (RFC 8072) instead of a plain PATCH, and what does it guarantee about edit order and atomicity?

level: seniorimportance: nice to knowfreq 6%

basics

~20 s

When one request must mix operations — create, delete, insert, merge, move, replace or remove — across several nodes. YANG Patch applies its edits in list order to a copy, validates the result once, and changes nothing if any edit fails.

open as a page

What does a RESTCONF ietf-restconf:errors response body contain, and how does the server choose its encoding?

level: seniorimportance: nice to knowfreq 8%

basics

~10 s

An ietf-restconf:errors body is a list of error entries, each with a mandatory error-type and error-tag plus optional error-app-tag, error-path, error-message and error-info; it is encoded as Accept asks, else like the request.

open as a page

A RESTCONF event-stream collector reconnects after a ten-minute outage; how do filter, start-time and stop-time recover only the missed interface events?

level: seniorimportance: nice to knowfreq 5%

basics

~20 s

On reconnect, the RESTCONF collector sets start-time to its last received eventTime and omits stop-time, so missed notifications replay and live delivery follows. filter, an XPath 1.0 expression, keeps only interface events. Replay needs replay-support on that stream.

open as a page

A RESTCONF PUT to the ietf-interfaces entry interface=eth0%2F1 carries a body whose name is eth0/2; what does the specification say, and how do you move that configuration?

level: seniorimportance: nice to knowfreq 5%

basics

~20 s

RFC 8040 requires the body's key values to equal the URI's and forbids PUT or PATCH from changing a key, so this is no rename. Moving the configuration means deleting eth0/1 and creating eth0/2, atomically in one YANG Patch when that matters.

open as a page