Forum Discussion

triSolutionFuse's avatar
10 years ago

add role to user via rest API

Hi all, We're running into an issue, that we cant seem to solve. We are trying to add a role to a user via the rest api, which works great on our staging environment, but on production does not wor...
  • triSolutionFuse's avatar
    triSolutionFuse
    10 years ago

    Turns out the issue was user error. The problem was in the reference to the user.id in the call:

     

    <#assign addRole = restadmin("/roles/id/${roleID}/users/add?role.user=id/${user.id}") />

    The API expects a computer readable number, with no commas. The above does not provide that if you have a large user id. Solution was to use this to strip the comma from user ids:

     

    <#assign addRole = restadmin("/roles/id/${roleCheck}/users/add?role.user=id/${user.id?c}") />