I'm designing a REST interface for my service. My service will be Role
and Permission
based. Therefor a Role
will contain Permission
s.
Meaning a Role
will have a collection of Permissions
-> roles/1/permissions
Now I would like to change the set of Permission
s for a Role
. As I understand, a correct request for this would be:
PUT roles/1/permissions
[
{
id: 1,
permissionName: "read"
}, {
id: 2,
permissionName: "write"
}, {
id: 3,
permissionName: "delete"
}
]
As this basically only maps existing permissions (/permissions
) to a role, there is a lot of unnecessary information sent. Especially if this example would contain a resource which is much more detailed as a Permission
.
Would it be okay to only send an array of ids in the body?
PUT roles/1/permissions
{
ids:[1,2,3]
}
I would reach the same, with only the information I actually need. Is there a problem with this approach? I'm afraid that this might hurting the stateless principle of REST.