Assign User Groups

Assign a user group to the user without logging in to Application Portal.

Operation Permissions

In Application Portal, the application must be granted the “Authorize users in this OU” permission.

Request Format

POST https://{apigw-address}/app-portal-service/v2.2/userGroup/appendUserGroups

Request Parameters (Body)

Name Mandatory/Optional Data Type Description
organizationId Mandatory String The organization ID. How to get organizationld>>
userId Mandatory String The user ID.
userGroupIds Mandatory List The ID of the user group to assign to the user.

Response Parameters

Name Data Type Description
data Boolean true indicates that the assignment was successful, false indicates that the assignment failed.

Error Codes

Code Description
31400 Errors such as incorrect parameters, empty parameters, character limits exceeded, and so on.
31403 The application has not been granted the “Authorize users in this OU” permission.
31404 Organization not found.

Samples

Request Sample

url: https://{apigw-address}/app-portal-service/v2.2/userGroup/appendUserGroups

method: POST

requestBody:
{"organizationId":"yourOrgId", "userId":"yourUserId","userGroupIds": ["ug1","ug2","ug3"]}

Return Sample

{
  "code": 0,
  "message": "OK",
  "data": true
}

Java SDK Sample

public class AppPortalSdkTest{
    @Test
    public void assignUserGroups() {
            ArrayList<String> userGroups = new ArrayList<>();
            userGroups.add("ug1");
            UserGroupsAppendRequest userGroupsAppendRequest = new UserGroupsAppendRequest("your_org_id", "your_user_id",userGroups);
            Response response = Poseidon.config(PConfig.init().appKey("your_access_key").appSecret("your_secret_key").debug())
                    .url("https://{apigw-address}").getResponse(userGroupsAppendRequest, Response.class);

            System.out.println("List organization res: " + JSON.toJSONString(response));

            assertNotNull("Response should not be null", userGroupsAppendRequest);
            assertNotNull("Response data should not be null", response.data);

    }
}