6.5 Interpret REST API status codes and response bodies from Catalyst Center and RESTCONF
ENCOR 350-401 v1.2 · 6.0 Automation and Artificial Intelligence
Every REST call answers with a status code and usually a body. ENCOR expects you to interpret both, for Catalyst Center and for RESTCONF: was it a success, did it create something, was the request wrong, was access refused, or did the server fail?
What you must know
- Group codes: 1xx informational, 2xx success, 3xx redirection, 4xx client error, 5xx server error.
- Know the common codes: 200, 201, 202, 204, 400, 401, 403, 404, 405, 409, 415, 429, 500, 503.
- Read Catalyst Center response bodies:
response,version, task IDs, error details. - Read RESTCONF error bodies (
ietf-restconf:errors).
The codes
| Code | Meaning | Typical cause |
|---|---|---|
| 200 OK | Success with a body | GET |
| 201 Created | A resource was created | RESTCONF POST |
| 202 Accepted | Accepted; processing continues | Catalyst Center async task: poll the task ID |
| 204 No Content | Success, no body | RESTCONF PUT, PATCH, DELETE |
| 400 Bad Request | Malformed request | Invalid JSON or wrong fields |
| 401 Unauthorized | Not authenticated | Missing or expired token |
| 403 Forbidden | Authenticated but not allowed | Role lacks permission |
| 404 Not Found | No such resource | Wrong URI or key |
| 405 Method Not Allowed | Verb not supported on this resource | POST to a read-only URI |
| 409 Conflict | Resource state conflicts | RESTCONF POST of something that exists |
| 415 Unsupported Media Type | Wrong Content-Type | application/json instead of application/yang-data+json |
| 429 Too Many Requests | Rate limited | Too many calls per minute |
| 500 / 503 | Server error / unavailable | Bug, overload or maintenance |
Response bodies
HTTP/1.1 202 Accepted
{"response": {"taskId": "5a7f…", "url": "/api/v1/task/5a7f…"}, "version": "1.0"}
HTTP/1.1 400 Bad Request
{"ietf-restconf:errors": {"error": [{"error-type": "application", "error-tag": "malformed-message", "error-message": "unexpected character ',' at line 4"}]}}A 202 from Catalyst Center means "started", not "done" (1); a 400 from RESTCONF names the error in its body (2).
Commands
curl -i … | Shows the status line and headers with the body. |
GET /dna/intent/api/v1/task/{taskId} | Catalyst Center: the result of an asynchronous task. |
Exam traps
- 401 = authentication problem; 403 = authorization problem.
- RESTCONF answers successful PUT/PATCH/DELETE with 204 and no body.
- 202 means accepted, not finished.
- 415 often means the wrong Content-Type for RESTCONF.
Check yourself
- A RESTCONF PATCH returns 204. Did it work?
- Yes: success with no body.
- A token-based call that worked an hour ago now returns 401. Why?
- The token expired; get a new one.
- Which code means the server is rate-limiting you?
- 429 Too Many Requests.