Hi all,
I'm working on a REST API and I had some questions about associations and the way to create resources.
In this case I have 'groups' and 'users', so I have the following URIs:
GET /groups > returns all groups
GET /groups/{id} > returns the indicated group
POST /groups > creates a group
GET /groups/{id}/users > returns users of the group
So far so god. The questions arise when I have to give a URI for the creation of users. Possibilities I think might work are:
POST /groups/{id}/users > creates a user under the group
POST /users > creates a user, but you have to indicate the group they belong to as part of the body
I guess I can provide two URIs, but this will mean that the user have two ways to achieve the same thing, which might not be good.
I would like to know what's your opinion based on your experience. Should I provide both URIs or just one of them? Do you see usability issues with any of these approaches?
Thanks!