Explain common HTTP response codes associated with REST APIs

📘Cisco DevNet Associate (200-901 DEVASC)


HTTP Response Codes Overview

When a client (like a web browser, script, or network tool) makes a request to a REST API, the server responds with a status code. This code tells you what happened with your request.

These codes are three-digit numbers, and they are grouped into five classes:

ClassRangeMeaning
1xx100–199Informational: The server received the request and is continuing the process. Rarely used in REST APIs.
2xx200–299Success: The request worked as expected.
3xx300–399Redirection: The client needs to take additional action (like following a new URL).
4xx400–499Client Error: Something was wrong with the request sent by the client.
5xx500–599Server Error: Something went wrong on the server side.

For DevNet exam purposes, you’ll mainly focus on 2xx, 4xx, and 5xx codes.


1. 2xx Success Codes

These codes indicate the request worked successfully.

200 OK

  • Meaning: The request was successful, and the server is returning the requested data.
  • Example: You request a list of devices from a network controller API. The server responds with the device list and a 200 OK.

201 Created

  • Meaning: A new resource has been successfully created.
  • Example: You send a POST request to add a new switch configuration. The server creates it and responds with 201 Created along with the new resource’s ID.

204 No Content

  • Meaning: The request was successful, but there is no data to return.
  • Example: You send a DELETE request to remove a VLAN from a switch. The VLAN is removed, but the server doesn’t need to return anything, so it replies 204 No Content.

2. 4xx Client Error Codes

These codes indicate the client (you) made a mistake in the request.

400 Bad Request

  • Meaning: The request is malformed or contains invalid syntax.
  • Example: You send a request to create a new router, but the JSON payload is missing a required field like hostname. The server replies 400 Bad Request.

401 Unauthorized

  • Meaning: The request lacks valid authentication credentials.
  • Example: You try to access an API endpoint without providing an API token. The server replies 401 Unauthorized.

403 Forbidden

  • Meaning: The server understood the request, but you don’t have permission.
  • Example: You try to delete a device configuration as a read-only user. The server replies 403 Forbidden.

404 Not Found

  • Meaning: The requested resource doesn’t exist.
  • Example: You try to get a VLAN with ID 100, but it doesn’t exist. The server replies 404 Not Found.

409 Conflict

  • Meaning: The request conflicts with the current state of the server.
  • Example: You try to create a device that already exists. The server replies 409 Conflict.

3. 5xx Server Error Codes

These codes indicate that the server failed to process a valid request.

500 Internal Server Error

  • Meaning: The server encountered an unexpected error.
  • Example: The API server crashes while processing your request. The client receives 500 Internal Server Error.

502 Bad Gateway

  • Meaning: The server received an invalid response from another server it was trying to communicate with.
  • Example: Your network API is behind a gateway that can’t reach the database, returning 502 Bad Gateway.

503 Service Unavailable

  • Meaning: The server is temporarily unable to handle the request (maintenance or overload).
  • Example: The network management API is overloaded with too many requests. It replies 503 Service Unavailable.

Quick Reference Table for Exam

CodeNameMeaningIT Example
200OKRequest succeededFetching device list
201CreatedResource createdAdding a new switch
204No ContentSuccess, no dataDeleting a VLAN
400Bad RequestRequest malformedMissing JSON field
401UnauthorizedAuthentication neededNo API token provided
403ForbiddenAccess deniedRead-only user tries to delete config
404Not FoundResource not foundVLAN ID doesn’t exist
409ConflictConflict with current stateDevice already exists
500Internal Server ErrorServer problemServer crashed
502Bad GatewayInvalid server responseAPI gateway can’t reach DB
503Service UnavailableServer overloadedToo many requests

Exam Tips

  1. Remember 2xx = success, 4xx = client error, 5xx = server error.
  2. Know the common codes for CRUD operations:
    • GET → 200 OK
    • POST → 201 Created
    • PUT → 200 OK or 204 No Content
    • DELETE → 204 No Content
  3. Think in IT terms: API calls to network devices, servers, or services, not real-world objects.
Buy Me a Coffee