Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

A request intended to fetch one item should target that individual resource; a request for the collection targets the set of items. If an unknown or missing ID instead returns the full collection, the response points to a possible mismatch between the requested target and the route or handler behavior—not a normal “not found” result. The specific cause cannot be identified without the route and code.

Single-resource requests and collection requests are different

In a REST-style API, a URL such as /items typically identifies a collection, while /items/123 identifies one item. The exact paths and conventions depend on the API, but the distinction matters: the server should not treat a request for a particular item as though it were a request for the whole collection.

API guidance from Zalando and SPS Commerce distinguishes these cases. A GET for an identified resource that does not exist should generally return 404. A collection that exists but has no members can return 200 with an empty result; whether a missing collection itself returns 404 depends on the API contract.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What 404 means—and what it does not mean

Under RFC 9110, GET asks for a current representation of the target resource. A 404 response means the server did not find a current representation for that target, or is unwilling to disclose that one exists. It does not prove that the resource is permanently absent.

So if GET /items/unknown-id returns the same list as GET /items, the key question is whether the request selected the intended target and whether the handler used the identifier. A collection response is not evidence that the requested individual resource was found.

How to investigate the unexpected collection response

The title alone does not identify a framework, route declaration, or implementation. Treat the following as hypotheses to test, not established causes:

  1. Compare requests. Send requests for the collection URL, a known item ID, an unknown ID, and an omitted or malformed ID. Record the HTTP method, exact path, status, and response shape for each.
  2. Verify the route match. Inspect which route handled each request. Check whether the individual-resource pattern requires an ID, whether parameter constraints behave as intended, and whether a broad fallback or collection route is taking precedence.
  3. Trace the parameter. Confirm that the handler receives the parsed ID and uses it in its lookup. A handler that ignores the parameter, or falls back to a collection query when parsing fails, can return a list instead of an individual resource.
  4. Check the API contract. Decide and document how the endpoint handles an unknown ID, a malformed or omitted ID, an empty collection, and a collection that does not exist. Verify the status and body against that contract.

Capture the matched route and parsed parameter alongside the response. That evidence helps distinguish a routing problem from a handler or lookup problem; without it, the cause remains uncertain.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Check authorization at the object lookup

Routing is only part of the diagnosis. A syntactically valid ID does not mean the caller is allowed to read the referenced record. OWASP’s IDOR guidance describes the risk of exposing an object through a reference without verifying that the requester is authorized to access it.

Scope the lookup to the authenticated user or tenant where appropriate, or perform an explicit object-level authorization check before returning the record. RFC 9110 allows a server to use 404 when it does not want to disclose that a forbidden resource exists.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Expected behavior at a glance

Request target Relevant condition Typical response
Individual resource, such as /items/123 The item exists and the caller may access it 200 with that resource’s representation
Individual resource The item is unknown or not disclosed to the caller 404 is generally appropriate
Collection, such as /items The collection exists and has no members Often 200 with an empty collection; document the contract
Collection The collection itself does not exist Contract-dependent; 404 may be appropriate

These are common API conventions, not proof of how a particular service is implemented. The route and response contract determine the correct behavior for that service.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.