To create a document for a project in an REST API,
POST /projects/1234/documents
What status is expected to return if the project with id=1234 doesn't exist?
Related to this question, but dealing with POSTs, not GETs.
To create a document for a project in an REST API,
POST /projects/1234/documents
What status is expected to return if the project with id=1234 doesn't exist?
Related to this question, but dealing with POSTs, not GETs.
Short answer: for most use cases similar to what you describe, 404.
More completely: the notion of "subresource" doesn't really exist in HTTP.
Yes, URI have a standard hierarchy of segments, and you can use relative resolution of dot segments to compute one URI from another. Those semantics do not translate into a hierarchy of resources.
/projects/1234/documents isn't a description of a path traversal, it's a key into a dictionary.
As far as HTTP is concerned, it is perfectly fine that /projects/1234/documents exists even though /projects and /projects/1234 do not.
Put slightly differently, the metadata in your response, which includes the status code, apply to the /projects/1234/documents resource, and not anything else.
Note that this goes both directions: not only does /projects/1234/documents not imply anything about /projects/1234, but it is also the case that it doesn't imply anything about /projects/1234/documents/5678.
Your best reference for getting your head around this is still going to be Fielding's thesis. It may also help to review RFC 7234