AI InterviewSearch…Search problems, topics, or pages…Ctrl KGet started
Mediumnetworkshttp

~75s

Reading an HTTP status code

A server fully understands a request but refuses to authorise it, and repeating the request with the same credentials will not help. Which HTTP status code fits?

Show the answer and the worked solution

Correct answer: C.

403 Forbidden

Worked solution

  1. 301 says the resource has moved to a new permanent URL, and 404 says the server cannot find it at all.
  2. 401 means authentication is missing or invalid and invites the client to retry with credentials.
  3. 403 Forbidden means the request was understood and any credentials were accepted, but the server refuses to authorise the action, so retrying identically achieves nothing.

Answer: 403 Forbidden.

The idea

Read the class first: 2xx succeeded, 3xx redirected, 4xx the client is at fault, 5xx the server is. Within 4xx, 401 is about who you are and 403 is about what you may do.

Shortcut. "Understood but refused, and retrying will not help" rules out a redirect (301), a missing resource (404) and 401, whose whole purpose is to invite a retry with credentials.

Common trap. "401 Unauthorized" matches the wording "refuses to authorise", but 401 really means unauthenticated and invites a retry with credentials.

Reading an HTTP status code — Aptitude Question

Reading an HTTP status code: A server fully understands a request but refuses to authorise it, and repeating the… Answer and worked solution on CodeKairo.

Question

A server fully understands a request but refuses to authorise it, and repeating the request with the same credentials will not help. Which HTTP status code fits?

Options

  1. 301 Moved Permanently
  2. 401 Unauthorized
  3. 403 Forbidden
  4. 404 Not Found
Show the answer and the worked solution

Correct answer: C. 403 Forbidden

Worked solution

  1. 301 says the resource has moved to a new permanent URL, and 404 says the server cannot find it at all.
  2. 401 means authentication is missing or invalid and invites the client to retry with credentials.
  3. 403 Forbidden means the request was understood and any credentials were accepted, but the server refuses to authorise the action, so retrying identically achieves nothing.

Answer: 403 Forbidden.

The idea

Read the class first: 2xx succeeded, 3xx redirected, 4xx the client is at fault, 5xx the server is. Within 4xx, 401 is about who you are and 403 is about what you may do.

Shortcut. "Understood but refused, and retrying will not help" rules out a redirect (301), a missing resource (404) and 401, whose whole purpose is to invite a retry with credentials.

Common trap. "401 Unauthorized" matches the wording "refuses to authorise", but 401 really means unauthenticated and invites a retry with credentials.

All OS, DBMS & Networks questions · placement mock tests