cancel
Showing results for 
Search instead for 
Did you mean: 

Add user to group with Rest API

jvacasp
Champ in-the-making
Champ in-the-making
Hello!!

I am trying to add a user in a group using Rest Services API.


http://localhost:8080/alfresco/service/api/groups/GroupRest/children/USER_UserRest

The group "GroupRest" and the user "UserRest" are existing in Alfresco. The system returns this error:

"org.alfresco.repo.security.authority.UnknownAuthorityException: 00161928 An authority was not found for USER_UserRest"

which is the problem?

Thanks!!
6 REPLIES 6

jpotts
World-Class Innovator
World-Class Innovator
I get the same result on 4.2.c. This does not appear to have anything to do with the web script…the same thing happens through a regular server-side JavaScript execution of the code. Have you checked Jira to see if this is a known issue? If not, it's going to need to be debugged and possibly reported as a bug.

Jeff

jpotts
World-Class Innovator
World-Class Innovator
I find that the call is successful if you use "UserRest" instead of "USER_UserRest", like this:
curl -X POST -uadmin:admin http://localhost:8080/alfresco/service/api/groups/GroupRest/children/UserRest

Jeff

jvacasp
Champ in-the-making
Champ in-the-making
Many Thanks Jeff!!!!!!!!! it works.

opbarth
Champ in-the-making
Champ in-the-making
I had to add the content type to be json:


/opt/alfresco/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts/org/alfresco/repository/groups/children.post.js (line 10):
<javascript>
if (headers["Content-Type"].indexOf("application/json") != 0)
</javascript>


curl -X GET -uadmin:admin -H "Content-Type: application/json" http://localhost:8080/alfresco/service/api/groups/GroupRest/children/UserRest

pieter_shimanow
Champ in-the-making
Champ in-the-making
If i do localhost:8080/alfresco/service/api/groups/newGroup/children/newUser
Both group and user exist.. but I get this :


{
   "data":{
         "authorityType": "GROUP",
         "shortName": "newGroup",
         "fullName": "GROUP_newGroup",
         "displayName": "New Group",
         "url": "/api/groups/newGroup"
           ,"zones":
           [
              "APP.DEFAULT",
              "AUTH.ALF"
           ]
}

}

ddelapasse
Champ in-the-making
Champ in-the-making
Help!  I feel like I'm missing the decoder ring.  I see lots of threads like these explaining the rest call perfectly like this:
curl -X POST -uadmin:admin http://localhost:8080/alfresco/service/api/groups/GroupRest/children/UserRest

BUT…there must be some kind of payload!!!  How am I supposed to know the required payload to add user ABC to group XYZ?