Changing the group membership of a user in bonitasoft portal doesn't show effect in the REST API calls

I was trying to change the group membership of the user using the administrator role on the portal, and i changed the role of one of the user and the tasks showing up for him changed accordingly on the portal under the tasks tab, but when i do REST API calls,I am receiving tasks of the previous group of the user only, can you please help me out with this bug?

AddUserMembership/ ProfileMemberCreator.setGroupId/.setRoleId Problem

I have a problem with setting UserMembership on a "Blank" User, created on Anonymous User, with his Form Inputs.
The user and his profile is created, but not his Usermembership on his UserDetails in Portal Bonita.
This is the Groovy code: