mydomain.com/users/by/organisation/{orgId}
What does "by" mean? That has no relationship to anything. Try to keep random words out of the URL.
Case 1: The call is expected to return "users" and therefore the "resource" (first part of the call) should relate to it.
That is not a rule that RESTful APIs enforce or expect. It is really not that common in the industry either, and I have worked with a LOOOT of APIs. Consider it to be a folder.
- /users - a list of users
- /users/1 - user with an ID of 1
- /users/1/organizations - the orgs that user belongs to
- /organizations - a list of orgs
- /organizations/1 - Organization number 1
- /organizations/1/users - The users for that organization
You are look at it like a programmer, like it is SOAP or a PHP function, trying to make getUsersByOrganization($orgId)
and that is not how REST works. :)
IF you have to stick to case 1 (first URI segment = return type) then do this:
That is perfectly RESTful and it is essentially just a filter. You could even do both, but I wouldn't. It is a relationship which has no place there. I try and keep filters to things like: ?active=true