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

The codes

CodeMeaningTypical cause
200 OKSuccess with a bodyGET
201 CreatedA resource was createdRESTCONF POST
202 AcceptedAccepted; processing continuesCatalyst Center async task: poll the task ID
204 No ContentSuccess, no bodyRESTCONF PUT, PATCH, DELETE
400 Bad RequestMalformed requestInvalid JSON or wrong fields
401 UnauthorizedNot authenticatedMissing or expired token
403 ForbiddenAuthenticated but not allowedRole lacks permission
404 Not FoundNo such resourceWrong URI or key
405 Method Not AllowedVerb not supported on this resourcePOST to a read-only URI
409 ConflictResource state conflictsRESTCONF POST of something that exists
415 Unsupported Media TypeWrong Content-Typeapplication/json instead of application/yang-data+json
429 Too Many RequestsRate limitedToo many calls per minute
500 / 503Server error / unavailableBug, 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

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.

More topics in 6.0 Automation and Artificial Intelligence