Merge User Accounts

Merge User Accounts

This API can be used to merge multiple users account (for consolidation) in case multiple accounts were created for the same person (As a result of data import, email id uniqueness not enforced etc). The API is a restrictive one and can be called by an admin of the site only. Any other user trying to invoke this API would result in an error being returned by the API.

 

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

userService.do

 

Parameter 2 - UserName

Username of any site administrator

 

Parameter 3 - Request Parameters

Name Value
dispatch mergeAccounts
mainUserName mandatory - surviving user's username
otherUserNames

mandatory - comma separated user names which would be merged in user identified by mainUserName. Merge operation merges

  • enrollments from all course sessions,
  • enrollments from all programs.
  • group memberships
  • event subscription
  • test attempts

If any course session, program, group or program is enrolled by both main and other usernames then merge process skips it. 

Other restrictions 

  • any of the other usernames account must not be site admin
deactivate

true | false - optional

If true, then user accounts identified by other usernames will be deactivated upon a successful merge.

 

Response

1. Response on successfully adding user to group

HTTP Response Code = HttpServletResponse.SC_OK

Response XML

<response code="0">
    <msgs>
         <msg>
             <code>0224</code>
             <value><![CDATA[Merged successfully.]]></value>
         </msg>
    </msgs>

</response>

 

2. Response on invalid user name

HTTP Response Code = HttpServletResponse.SC_NOT_FOUND

Response XML

<response code="-1">
    <msgs>
         <msg>
             <code>0004</code>
             <value><![CDATA[Unable to find User with matching id]]></value>
         </msg>
    </msgs>
</response>

 

3. 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("mainUserName", "jdoe");

    parameters.put("otherUserName", "jdoe1,jdoe2,jdoe3");

    parameters.put("dispatch", "mergeAccounts");
 
    String retStr = connection.invokeApi("userService.do", "chenry", parameters);
    System.out.println(retStr);
   


Rating: