Interpret REST API response codes and payload results using Cisco DNA Center and RESTCONF

📘CCNP Encore (350-401-ENCORE-v1.1)


1. What This Topic Is About (Exam View)

In this section, the exam checks whether you can:

  • Understand REST API response codes
  • Interpret API response payloads (JSON data)
  • Know how Cisco DNA Center APIs work
  • Understand how RESTCONF works
  • Read API responses and know what success or failure looks like

⚠️ You are NOT required to write complex code.
You are required to read, understand, and interpret API responses.


2. What Is a REST API (Simple Definition)

A REST API allows one system to communicate with another system over HTTP.

In networking:

  • A controller (like Cisco DNA Center) exposes APIs
  • Engineers or automation tools send requests
  • The controller sends back responses

These responses contain:

  • A status code (number)
  • A payload (usually JSON data)

3. What Is Cisco DNA Center in API Context

Cisco DNA Center (DNAC) is a network controller that:

  • Manages devices
  • Automates configurations
  • Collects network data
  • Provides REST APIs for automation

Using APIs, you can:

  • Get device inventory
  • Check network health
  • Push configurations
  • Monitor issues

Cisco DNA Center APIs always return:

  • An HTTP response code
  • A JSON payload

4. What Is RESTCONF

RESTCONF is a REST-based protocol used to:

  • Configure network devices
  • Retrieve operational data
  • Use YANG data models

RESTCONF:

  • Uses HTTP methods (GET, POST, PUT, DELETE)
  • Uses JSON or XML
  • Is commonly used with Cisco IOS-XE devices

RESTCONF responses also include:

  • HTTP response codes
  • Structured payloads

5. Understanding HTTP Response Codes (VERY IMPORTANT)

Response codes tell you what happened to your request.

The exam focuses mainly on meaning, not memorization of all numbers.


5.1 2xx – Success Responses

These mean the request worked correctly.

CodeMeaningExplanation
200 OKSuccessRequest completed successfully
201 CreatedCreatedResource was successfully created
202 AcceptedAcceptedRequest accepted and processed later
204 No ContentSuccess, no dataAction succeeded, but no data returned

Exam Tip:
If you see 2xx, the operation was successful.


5.2 3xx – Redirection Responses

Rarely tested, but good to know.

CodeMeaning
301 / 302Redirected to another location

Usually handled automatically by tools.


5.3 4xx – Client Errors (Your Mistake)

These mean the request is wrong.

CodeMeaningExplanation
400 Bad RequestInvalid requestWrong format or missing data
401 UnauthorizedAuthentication failedInvalid or missing token
403 ForbiddenNot allowedUser lacks permission
404 Not FoundResource missingAPI endpoint or object not found
409 ConflictConflictResource already exists

Exam Tip:
4xx errors mean the client did something wrong.


5.4 5xx – Server Errors (Controller Problem)

These mean the server failed.

CodeMeaning
500 Internal Server ErrorServer crashed or failed
503 Service UnavailableService is down or overloaded

Exam Tip:
5xx errors are not caused by the user request.


6. Understanding API Payloads (Response Body)

A payload is the data returned by the API.

Most Cisco APIs use JSON.


6.1 Common JSON Structure in Cisco DNA Center

Typical response contains:

{
  "response": { },
  "version": "1.0"
}

Or:

{
  "response": [ ],
  "page": { }
}

6.2 Key Payload Components

FieldMeaning
responseMain data returned
errorCodeError identifier
messageHuman-readable message
executionStatusUrlAsync task tracking
idUnique identifier
statusOperation state

7. Synchronous vs Asynchronous Responses

7.1 Synchronous Response

  • API responds immediately
  • Common with GET requests
  • Response contains data directly

Example:

  • Getting device inventory

7.2 Asynchronous Response (Very Important for DNAC)

Cisco DNA Center often uses asynchronous APIs.

Process:

  1. API returns 202 Accepted
  2. Payload contains a task ID
  3. Client checks task status later

Example payload:

{
  "response": {
    "taskId": "abc123"
  }
}

You must:

  • Use the task ID
  • Query the task status API

Exam Tip:
202 + task ID = asynchronous processing


8. Interpreting Error Payloads

Error responses usually include:

{
  "errorCode": "INVALID_REQUEST",
  "message": "Invalid input provided"
}

Key points:

  • Error code explains what failed
  • Message explains why it failed
  • Status code explains who is responsible

9. RESTCONF Response Interpretation

RESTCONF responses follow the same logic:

9.1 Success Example

  • 200 OK
  • JSON payload containing YANG-modeled data

9.2 Configuration Change

  • 201 Created → new config applied
  • 204 No Content → config changed, no data returned

9.3 Error Example

  • 400 → invalid YANG structure
  • 401 → authentication failure
  • 409 → configuration conflict

10. Authentication and Tokens (Context Understanding)

Cisco DNA Center APIs use:

  • Token-based authentication

Flow:

  1. Authenticate
  2. Receive token
  3. Use token in API headers
  4. Invalid or expired token → 401 Unauthorized

11. Exam-Focused Summary (Must Remember)

You MUST Know:

✔ Meaning of 2xx, 4xx, 5xx
✔ Difference between 200, 201, 202, 204
✔ What a JSON payload is
✔ How to interpret task-based responses
✔ How Cisco DNA Center uses asynchronous APIs
✔ RESTCONF uses YANG + REST + HTTP codes


12. One-Line Exam Memory Rules

  • 2xx = Success
  • 4xx = Client error
  • 5xx = Server error
  • 202 + task ID = async operation
  • JSON payload = response data
  • RESTCONF = REST + YANG

Buy Me a Coffee