Reputation: 1855
After a bit of reading, I think I get what the whole RESTfull thing is about. That being said, in my reading I've seen a couple different ways of structuring the URI's.
Collection: /user
or /user/
Element: /user/123
or /user?id=123
Wikipedia uses /user
+ /user/123
, but Wikipedia clearly isn't the master source.
My personal thoughts were that going with /user/
+ /user/123
or /user
+ /user?id=123
made a little more sense since you immediately know if the resource operating on is a collection or element.
Perhaps what I'm asking is, are any of these URI combinations the wrong way to go about it? Thank you.
Upvotes: 0
Views: 40
Reputation: 13682
Some would argue it's a matter of personal preference, but many feel that using plural names for collections is strictly better than singular - /users
vs /user
. If the "id" is the unique identifier for the user, then it's traditional for that to be a full resource endpoint - /users/123
, not /users?id=123
. On the other hand, if you want all users whose name is "Bob", then you would do /users?firstName=Bob
.
Upvotes: 1