Assigning roles through REST-API

Hi,
I am using REST-API add-on to synchronize data with our other systems and now I need to assign basic role for our users. But there is nothing in JMIX to assign more roles on faster way. So I wanted to assign them through API, but I didnt find any way to edit entity for role assigments.
Is there any way, how can I prepare this function for roles?
Thank you
Paul

Hi,

In order to assign roles programmatically you must create and persist an instance of io.jmix.securitydata.entity.RoleAssignmentEntity, e.g.

RoleAssignmentEntity roleAssignmentEntity = metadata.create(RoleAssignmentEntity.class);
roleAssignmentEntity.setRoleCode(roleCode);
roleAssignmentEntity.setUsername(username);
roleAssignmentEntity.setRoleType(RoleAssignmentRoleType.RESOURCE);

If I misunderstood your question, then please explain in more details.