Let's say I have a resource /books
, with a parameter ?author_id=
. What should be returned if no author_id
parameter is specified, e.g., /books
as opposed to /books?author_id=42
? Based partially on this answer, I have decided that if you hit /books?author_id=42
you will get an empty collection if author 42
has no books, instead of e.g., returning a 404.
However, in the case that client_id
is null, I am not sure if I should treat this case the same way (i.e., the author with the ID of null has no books) or if it should be something like a 400, treating null as an invalid value for client_id
.
Note also that books
is a contrived example, and that in my case, I cannot simply return all "books" if the user hits /books
. Assume it is a case that only the author has access to their books.