When constructing a REST service, I try to focus on the object in question and use the JSON to represent the structure of the data.
In this example, the object to be modified is the group. I would put this at the base of the URI and not have it buried in the middle.
/api/groups/{groupId}
This should be valid because (hopefully) group IDs are unique across the application.
Next is the question of how to update members.
I imagine a JSON which looks something like:
{
"groupId": "1111",
"groupName": "A Group",
"ownerId": "2222",
"membersIds": [ "2222", "3333", "4444" ]
}
The first option would be to PUT the whole object.
PUT /api/groups/1111
{
"groupId": "1111",
"groupName": "A Group",
"ownerId": "2222",
"membersIds": [ "2222", "3333", "4444" ]
}
This is a simple API. A client would use a GET to get the current data, make changes, then PUT the result. It would be up to the server to validate the update as a whole, or reject the update as a whole if there is some error.
I understand this may not always be desirable, so I could understand wanting a shortcut which would only update members.
To this end here is the members shortcut:
/api/groups/{groupId}/members
with the corresponding JSON:
[ "2222", "3333", "4444" ]
This would still be a PUT because you are updating the existing data.
PUT /api/groups/1111/members
[ "2222", "3333", "4444" ]
The PUT would replace all the current members with the members in the array. The current members could be requested with GET /api/groups/1111/members
. It would be the client's responsibility to add new members to the current members.
This is still not what you asked for. You want a shortcut to simply add members. Here my method breaks down. You are not using the URI to represent the structure of the data, you are using the URI to perform an action with the data. This is not very RESTful (IMHO), but lots of people do it.
In the past, I've use CGI parameters to explicitly show an action.
/api/groups/{groupId}?action=addMembers
Finally, we get to something that looks like what you asked for.
POST /api/groups/1111?action=addMembers
[ "3333", "4444"]
To me, it doesn't look very RESTful, but utility trumps ideology and if this is exactly what you need, then here it is.