title: How about using URI path variables for an HTTP POST?
body: <p>I've searched a lot but I couldn't find the proper answer to my question regarding my conditions.<br>
  I'm building a REST API, and the case, which seems a border line case to me, is the following:
  <br><br>
  -I'm dealing with two entities, Users and Roles. An User can have multiple roles assigned.<br>
  -To assign a Role to a User, the Role must be already in the DataBase.<br>
  -To assign a Role to a User, the only thing needed is the 'code' of the role, that is a short string.<br>
  -The uri path template used now is:<br>
  --Users: localhost:8080/api/users<br>
  --Given User: localhost:8080/api/users/{userId}<br>
  --Roles of a given User: localhost:8080/api/users/{userId}/roles <br>
  <br>
  Now, to 'link' a given User with a given Role, two options come to my mind.<br>
  -The first is the one that sounds as best practice in any scenario, sending the post data in the body, perhaps as a JSON.<br>
  -The other one, sending it through the uri and with an empty body. For example, to link User with id U001 with role R001, one would have to post to the following uri sending no data in the body: localhost:8080/api/users/U001/roles/R001<br>
  <br>
  The thing is that I don't mind using the first option, and it seems to be the best and most correct one, but in this particular case, I'm not sure wether it is better to send an almost empty body (because it only holds the role id, a very short string) posting it to 'localhost:8080/api/users/U001/roles' or skipping the body and just sending the role id through the uri as a path parameter like localhost:8080/api/users/U001/roles/R001 <br></p>
  
  <p>Thank you all in advance for your help.<br></p>