Add Groups (v2)

REST Resource

POST /interop/rest/security/v2/groups/add

Table 2-61 Tasks for Add Users to Group

Task Request REST Resource
Add groups POST /interop/rest/security/v2/groups/add

Request

Supported Media Types: application/json

Table 2-62 Parameters

Name Description Type Required Default
groupname Name of group to add Payload Yes None
description Description of group Payload No None
userlogin The user login of the user to add to the group Payload No None
groupname Name of the group to add as a member of this group Payload No None

Example URL and Payload

https://<BASE-URL>/interop/rest/security/v2/groups/add

Payload with Only Groups

{
	     "groups": 
            [
            {
                 "groupname": "GroupA",
                 "description": "GroupADescription"
      
    	 },
    	 {
                  "groupname": "GroupB",
                  "description": "GroupBDescription"
    	 }      
	     ]
}

Payload with Groups and Members

{
  "groups": [
    {
      "groupname": "GroupA",
      "description": "GroupADescription",
      "members": {
        "users": [
          {
            "userlogin": "jdoe"
          },
          {
            "userlogin": "chris"
          }
        ],
        "groups": [
          {
            "groupname": "User"
          },
          {
            "groupname": "Interactive User"
          }
        ]
      }
    },
    {
      "groupname": "GroupB",
      "description": "GroupBDescription",
      "members": {
        "users": [
          {
            "userlogin": "jane"
          },
          {
            "userlogin": "alex"
          }
        ],
        "groups": [
          {
            "groupname": "Analyst"
          },
          {
            "groupname": "Super User"
          }
        ]
      }
    }
  ]
}

Response

Supported Media Types: application/json

Table 2-63 Parameters

Name Description
links Detailed information about the link and HTTP call type
status

Identifies the status of the operation

  • 0 - Operation succeeded

  • 1 - Operation failed

error Detailed information about the error
details Detailed status of the operation performed. Total number of records processed, succeeded, and failed, and the reason for why they failed.

Examples of Response Body

The following examples show the contents of the response body in JSON format:

Example 1: REST API Completes without Errors

{
	"links": {
    		"href": "https://<BASE-URL>/interop/rest/security/v2/groups/add",
    		"action": "POST"
	},
	"status": 0,
	"error": null,
	"details": {
		"processed": 2,
		"succeeded": 2,
		"failed": 0,
		"faileditems": null
	}
}

Example 2: REST API Completes with Errors

{
	"links": {
    		"href": "https://<BASE-URL>/interop/rest/security/v2/groups/add",
    		"action": "POST"
	},
	"status": 1,
	"error": {
		"errorcode": "EPMCSS-21119",
		"errormessage": "Failed to add groups. Invalid or insufficient parameters specified. Provide all required parameters for the REST API."
	},
	"details": null
}

Example 3: REST API Completes with Partial Errors

{
    "links": {
        "href": "https://<BASE-URL>/interop/rest/security/v2/groups/add",
        "action": "POST"
    },
    "status": 0,
    "error": null,
    "details": {
        "processed": 3,
        "succeeded": 1,
        "failed": 2,
        "faileditems": [
            {
                "groupname": "GroupA",
                "errorcode": "EPMCSS-21140",
                "errormessage": "Failed to add group. Group already exists in System. Provide different group name."
            },
            {
                "groupname": "GroupB",
                "errorcode": "EPMCSS-21231",
                "errormessage": "Failed to add group. Unable to add member(s). Provide valid member(s).",
                "erroritems": {
                    "groups": [
                        {
                            "groupname": "GroupC",
                            "errorcode": "EPMCSS-21228",
                            "errormessage": "Group GroupC does not exist.  Provide a valid groupname."
                        }
                    ],
                    "users": [
                        {
                            "userlogin": "UserA",
                            "errorcode": "EPMCSS-21230",
                            "errormessage": "User UserA does not exist.  Provide a valid userlogin."
                        }
                    ]
                }
            }
        ],
        "items": null
    }
}

Sample cURL Command Basic Auth

curl -X POST -s -u '<USERNAME>:<PASSWORD>' -H 'Content-Type: application/json' -d '{"groups":[{"groupname":"GroupA","description":"GroupADescription"},{"groupname":"GroupB","description":"GroupBDescription"}]}' 'https://<BASE-URL>/interop/rest/security/v2/groups/add'
curl -X POST -s -u '<USERNAME>:<PASSWORD>' -H 'Content-Type: application/json' -d '{"groups":[{"groupname":"GroupA","description":"GroupADescription","members":{"users":[{"userlogin":"jdoe"},{"userlogin":"chris"}],"groups":[{"groupname":"User"},{"groupname":"Interactive User"}]}}]}'  'https://<BASE-URL>/interop/rest/security/v2/groups/add'

Sample cURL Command OAuth 2.0

curl -X POST --header "Authorization: Bearer <OAUTH_ACCESS_TOKEN>" -H 'Content-Type: application/json' -d '{"groups":[{"groupname":"GroupA","description":"GroupADescription"},{"groupname":"GroupB","description":"GroupBDescription"}]}' 'https://<BASE-URL>/interop/rest/security/v2/groups/add'
curl -X POST --header "Authorization: Bearer <OAUTH_ACCESS_TOKEN>" -H 'Content-Type: application/json' -d '{"groups":[{"groupname":"GroupA","description":"GroupADescription","members":{"users":[{"userlogin":"jdoe"},{"userlogin":"chris"}],"groups":[{"groupname":"User"},{"groupname":"Interactive User"}]}}]}' 'https://<BASE-URL>/interop/rest/security/v2/groups/add'