REST API code/message for missing parent resource -


i'm looking guidance correct response code & message when requesting resource forms part of resource.

for example, request on:

users/{id}

where user not exist return 404, message of user resource not found.

my question is, should following return when no user resource found:

users/{id}/friends

i'm returning same code/message in first example. should returning message relating friends resource? think it's more helpful make api client aware parent resource isn't found, incase have larger uri chain.

in particular example, if point let client differentiate between friends request non-existent user, , friends request user has no friends, think make sense return 404 in first case, , 200 empty set in second.

in other words, "none" valid value friends. there's no case user exists (potentially empty) list of friends doesn't, there's never ambiguity in issuing 404 parent resource.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -