I’m designing an application following REST specification but I’m unsure how to structure the following.
I have projects, which follow the basic CRUD process. I also have users which also follow a basic CRUD process. However I have an operation of adding users to a project and I’m not sure how to make the request.
A user can have multiple projects, so I’m thinking it should be some kind of PUT request, but the project id is not really part of the user model.
PUT /users/project/3
Any suggestions on how to approach this?
It sounds as though the User can have many Projects and a Project can have many Users. In that case managing that relationship is best done through a join table that you could name something like Participants which would have a user_id and a project_id.
Then you can choose whether to manage Participants through a User or through a Project. To me it would make sense to manage your Projects Participants, and because you are creating a new Participant it is a POST.
The payload would contain the user_id.