Forum Discussion

surendrakalapa's avatar
surendrakalapa
Contributor
3 years ago

What permissions are needed for an API call that adds a role which has name spaces for another user

We need to update the user roles (a role which happens to also imply a badge) eg: ECMS 1,ECMS 2  which has name spaces  to an user. we tried to do that as below but its showing error message.

PUT : http://community.lithium.com/community-name/api/2.0/users/2

BODY:


"data": {
"type": "user",
"roles_to_add": ["t:ECMS 2"]
}
}

HEADERS: session key

Response:    403 forbidden

{
"status": "error",
"message": "Permission Denied",
"data": {
"type": "error_data",
"code": 414,
"developer_message": "UserRef[id=294] does not have access to RequiredPermissions[(allow_creation_of_external_badges)] on CommunityByDisplayIdRef[nodeType=StandardNodeType[nodeType=lithium.coreapi.community.ICommunity,entityTypeKey=EntityTypeKey[community],entityTypeUid=4,hashCode=1653728538],displayId=yuzje69629]",
"more_info": ""
},
"metadata": {}
}

 

Thanks

surendra

2 Replies

  • Hi Caroline,

    For (1) we found the solution that we can encode entire role in single quotes like 

    "roles_to_add": ["'t:ECMS 1'"] and we see its 200-success but still role is not adding. it looks like access issue and for that we need fix for (2).
     
     
     

     

  • Hi Surendra,

    I think there are two questions you are asking here:

    (1) How do you encode user role names that have spaces?

    (2) What permissions are needed for an API call that adds a role for another user (a role which happens to also imply a badge)?

    ----

    For (1), I do not know the answer but I hope someone here does! I did find this thread How to get role details by name which has space which may be helpful.

    For (2), does your API user have permission "Create, edit, publish, and delete badges" and "Manage roles in user profiles"? If so and you are still getting this error, there may be additional permissions required that I'm not aware of.

    I hope that is helpful, and I hope someone here can let us know how to encode spaces and also let us know if there are additional permissions required to add roles via API.