API - Enroll Users in Program

Enroll User(s) to Program

This API can be used to enroll users to a program.

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

enrollmentService.do

Parameter 2 - UserName

Username of any site administrator

Parameter 3 - Request Parameters

Name Value
dispatch enrollUsersInProgram
Either usernames or ids is required
programId program id to enroll in to
extId Optional - external id of program (instead of program id)
usernames

comma separated usernames

e.g. adoe,bdoe,cdoe,ddoe....

ids

81154232-7e81-11e4-b5ad-fb29daca67a3, xxx-xxx-xxx-xxx-xxx

comma separated user ids

(Optional .. specify either usernames or ids)

sendMail true or false. Send true to send enrollment emails.

 

Response

1. Response on successfully adding user to group

HTTP Response Code = HttpServletResponse.SC_OK

Response XML

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

</response>

 

2. Response for unauthorized access

HTTP Response Code = HttpServletResponse.SC_UNAUTHORIZED

Response XML

<response code="-1">
    <msgs>
         <msg>
             <code>0005</code>
             <value><![CDATA[You are not allowed to perform this action.]]></value>
         </msg>
    </msgs>
</response>

 

Code Snippet

    /*  Check API Call for detail generic code */
    Map<String, String> parameters = new HashMap<String, String>();
    parameters.put("programId", "81154132-7e81-11e4-b5ad-f229aaca67a3");

    parameters.put("usernames", "adoe,bdoe,cdoe");
    parameters.put("dispatch", "enrollUsersInProgram");
   
    String retStr = connection.invokeApi("enrollmentService.do", "chenry", parameters);
    System.out.println(retStr);


Rating: