The error was caused by the fact that i had sub-groups in my organisation. And as apparently he donât hundle this . So i deleted all sub-groups and left just groups, and it works . Thank you
And for profil i did this :
if (field_priv_choix=="Administrateur") { apiAccessor.getProfileAPI().createProfileMember(2, user.getId(), group.getId(), role.getId()) } else if (field_priv_choix=="Utilisateur") { apiAccessor.getProfileAPI().createProfileMember(1, user.getId(), group.getId(), role.getId()) }