1

Greetings to the community! I am trying to create a new user group on alfresco using the REST API following this guide https://api-explorer.alfresco.com/api-explorer/#!/groups/createGroup. I am using Postman to make the REST calls. I have successfully so far managed to create new users using the (/people) (POST) method like shown below:

POST: http://localhost:8080/alfresco/s/api/people?alf_ticket=TICKET_<<my_alf_ticket>> and the following JSON in the Body:

{
    "userId": "user",
    "password": "pass",
    "userName": "user",
    "firstName": "user",
    "lastName": "user",
    "email": "user@user.com"
   }

Unfortunately, when I am similarly trying to create a new group like following

POST: http://localhost:8080/alfresco/s/api/groups?alf_ticket=TICKET<<my_alf_ticket>>

and in the body section

{
            "authorityType": "GROUP",
            "shortName": "GROUP1",
            "fullName": "GROUP_GROUP1",
            "displayName": "GROUP_GROUP1"
   }

I am facing the following error

Any help would be greatly appreciated :)

NickAth
  • 1,089
  • 1
  • 14
  • 35
  • Based on `/alfresco/s/index/package/org/alfresco/repository/groups` there isn't a `POST` webscript at `/api/groups` - what exactly are you trying to do here, add a new root group, or a new subgroup, or something else? – Gagravarr Oct 18 '18 at 16:23
  • Thanks for your quick reply, I am trying to create a new root group and then insert my newly created user inside it. – NickAth Oct 18 '18 at 16:30
  • @NickAth What Alfresco version are you use? – mrgrechkinn Oct 18 '18 at 18:18
  • @mrgrechkinn I am using alfresco 6.0.0 – NickAth Oct 18 '18 at 18:26

1 Answers1

2

This is old api:

1) POST http://localhost:8080/alfresco/s/api/rootgroups/{shortName} to create group

2) POST http://localhost:8080/alfresco/s/api/groups/{shortName}/children/{fullAuthorityName} Adds a group or user to a group.

For new api you should use:

POST http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/groups

CURL

curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'Authorization: Basic YWRtaW46YWRtaW4=' -d '{
  "id": "TEST_GROUP_ID",
  "displayName": "Group for tests"
}' 'https://api-explorer.alfresco.com/alfresco/api/-default-/public/alfresco/versions/1/groups'

Response

{
  "entry": {
    "isRoot": true,
    "displayName": "Group for tests",
    "id": "GROUP_TEST_GROUP_ID"
  }
}
mrgrechkinn
  • 883
  • 8
  • 19
  • Thanks for the clarification :). So i assume I should use the new api since I am using alfresco 6.0.0. I POST the following http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/groups with body { "displayName": "ALFRESCO_ADMINISTRATORS", "zones": [ "APP.DEFAULT","AUTH.ALF" ] } And come with the following error "errorKey": "groupId is null or empty"," and when i try to include it in my JSON body i get ""errorKey": "Could not read content from HTTP request body: Unrecognized field \"groupId\" (Class org.alfresco.rest.api.model.Group), any ideas?? – NickAth Oct 18 '18 at 19:27
  • @NickAth Try to read api documentation) id - for groupid, displayName and parentIds – mrgrechkinn Oct 18 '18 at 19:33