200-301 - Automation and Programmability (10% of the exam) - Section 6.5
Describe characteristics of REST-based APIs (CRUD, HTTP verbs, and data encoding) and recognise the components of JSON-encoded data.
Describe a REST API as stateless HTTP calls that map CRUD operations to the GET, POST, PUT/PATCH, and DELETE verbs and return status codes signalling success or error. Recognise JSON structure - objects of key/value pairs, arrays, strings, numbers, booleans, and null - and parse a small JSON payload to read the value of a given key, the most common data-encoding format in network APIs.
REST APICRUD and HTTP verbsHTTP status codesJSON objects and arraysData encoding
Practice question for this objective
lock_openFree sampleAutomation and Programmabilitymedium
A network engineer inspects the JSON body returned by a switch API for one interface:
{
"name": "GigabitEthernet0/1",
"mtu": 1500,
"enabled": true,
"vlans": [10, 20, 30]
}
The engineer must explain to a colleague how the individual values in this document are encoded according to the JSON data format. Which two statements correctly describe the encoding of the values shown? Select TWO.
AThe value 1500 is a JSON number and is written without surrounding quotation marks.check_circle Correct
BThe value of "vlans" is a JSON array, an ordered list of values enclosed in square brackets.check_circle Correct
CThe value true is a quoted JSON string because every JSON value must be wrapped in quotation marks.
DThe value "GigabitEthernet0/1" is a JSON number because it contains the digits 0 and 1.
EThe pair "mtu": 1500 is itself a JSON array because it lists a name beside a value.
Recognise how JSON encodes value types: numbers and booleans are unquoted literals, strings are quoted, and square brackets denote an ordered array. JSON distinguishes value types by syntax rather than by the characters they contain. Numbers such as 1500 and booleans such as true are written as bare literals with no quotation marks, strings are always wrapped in double quotes, and an ordered list of values is delimited by square brackets to form an array. A quoted token is a string even when it contains digits, and a key-value pair belongs to an object, not an array.
Why A is correct: JSON encodes numeric values as bare literals, so 1500 carries no quotes and is interpreted as a number rather than text.
Why B is correct: Square brackets delimit a JSON array, and the comma-separated members 10, 20 and 30 form the ordered list of values it holds.
Why C is wrong: It is tempting to treat all values as text, but true is a bare JSON boolean literal and is wrong because quotes would instead make it a string.
Why D is wrong: Embedded digits look numeric, yet the double quotes make this a JSON string, so classing it as a number misreads the encoding.
Why E is wrong: A name beside a value resembles a list, but this is a key-value member of a JSON object, not an array delimited by square brackets.
Answers that look right on this material and are not. Each one is a distractor from a different question in the 200-301 bank for this domain.
GET, because it retrieves the controller state and registers the new VLAN as a side effect of the read
errorWhy it is wrong: GET is the Read operation and is defined as safe, meaning it must not change server state, so it cannot create a resource.
POST, because it submits new data values to the interface resource on the controller
errorWhy it is wrong: POST is tempting because it does send data in the body, but in REST it creates a new subordinate resource rather than modifying an existing one, so it does not map to editing the existing interface object.
switches[2].mgmt, returning 10.10.0.12
errorWhy it is wrong: This treats the array as one-indexed; JSON arrays are zero-indexed, so index 2 is out of range for a two-element array and would not return the second element.