Api - Group Hierarchy

Group Hierarchy List

This API is used to obtain the list of groups for a given parent. For each group, the API returns the group id, group name, code and group owners name and username.

 

API Details

Signature of API call

connection.invokeApi(String uri, String realUserName, Map<String, String> requestParameters);

See details about invoking API in general

 

Parameter 1 - URI

groupService.do

 

Parameter 2 - UserName

Username of the user (for my groups) and site admin(for site groups)

 

Parameter 3 - Request Parameters

Name Value
dispatch getDescendentGroups
xml true
id id of the parent group. If not specified, then returns all top level groups. (either id, code or groupName is required)
code code of the children (or descendant) groups to match (either id, code or groupName is required). Exact match is performed on group's code (case insensitive)
groupName name of the children (or descendant) groups to match (either id, code or groupName is required). Exact match is performed on group name (case insensitive)
directChild specifies, whether to return immediate children or all descendants (all levels in subtree starting from this parent group).
pageSize Optional - Default value is 0
currPage

Optional - default value is 0.

 

to fetch multiple pages, this api needs to be called multiple times, with value for currPage parameter 0, 1, 2 .... upto the total number of items available from the api. 

 

First call to the API carries a response XML which contains information about the total number of items available.

 

Response

Response on successfully getting the event list

HTTP Response Code = HttpServletResponse.SC_OK

Response XML

<response code="0">
   <msgs>
      <msg>
         <code>0</code>
         <value>
            <![CDATA[Success]]>
         </value>
      </msg>
   </msgs>

   <data>
      <groups numItems="3" currPage="-1" pageSize="10">

         <group id="c4f78d58-c31b-11e1-a74c-e96024937694">
            <name><![CDATA[Fave3Group1]]></name>

           <code><![CDATA[12345]]></code>
            <membercount>1</membercount>
            <groupOwnerFirstName>Chris</groupOwnerFirstName>
            <groupOwnerLastName>Henry</groupOwnerLastName>
            <groupOwnerUserName>chenry</groupOwnerUserName>
         </group>
    
         <group id="db960dec-c31a-11e1-a74c-e96024937694">
            <name><![CDATA[Fave3Group2]]></name>
            <membercount>1</membercount>
            <groupOwnerFirstName>Chris</groupOwnerFirstName>
            <groupOwnerLastName>Henry</groupOwnerLastName>
            <groupOwnerUserName>chenry</groupOwnerUserName>
         </group>
    
         <group id="e48b628e-c31b-11e1-a74c-e96024937694">
            <name><![CDATA[Fave3Group3]]></name>
            <membercount>1</membercount>
            <groupOwnerFirstName>Chris</groupOwnerFirstName>
            <groupOwnerLastName>Henry</groupOwnerLastName>
            <groupOwnerUserName>chenry</groupOwnerUserName>
         </group>

      </groups>
   </data>

</response>

 

Code Snippet

 

    /*  Check API Call for detail generic code, returns all top level groups */
    Map<String, String> parameters = new HashMap<String, String>();
    parameters.put("dispatch", "getDescendentGroups ");
    parameters.put("xml", String.valueOf(true));
    parameters.put("pageSize", "10");
    String retStr = connection.invokeApi("groupService.do", "adminusername", parameters);
    System.out.println(retStr);

/*

example - get all immediate children of a group

*/

Map<String, String> parameters = new HashMap<String, String>();
    parameters.put("dispatch", "getDescendentGroups ");

    parameters.put("directChild", String.valueOf(true));

    parameters.put("id", "xxxx-xxxx-xxxx-xxxx");
    parameters.put("xml", String.valueOf(true));
    parameters.put("pageSize", "10");
    String retStr = connection.invokeApi("groupService.do", "adminusername", parameters);
    System.out.println(retStr);

 

/*

example - get all descendant a group that match a code

*/

Map<String, String> parameters = new HashMap<String, String>();
    parameters.put("dispatch", "getDescendentGroups ");

    parameters.put("directChild", String.valueOf(false));

    parameters.put("id", "xxxx-xxxx-xxxx-xxxx");

    parameters.put("code", "xyz");
    parameters.put("xml", String.valueOf(true));
    parameters.put("pageSize", "10");
    String retStr = connection.invokeApi("groupService.do", "adminusername", parameters);
    System.out.println(retStr);


Rating: