API - Change User's Origin Site

Change User's Origin Site

This API can be used to change user's origin site in a multi - microsite setup. 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. This API also enforces checks that both current origin site of the user and site you want to be changed to, must belong to same namespace. Also, this API won't update origin site of the user, who is an admin in the current origin site.

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 changeOriginSite
userName, id or openId is required
userName jdoe
id a570e68e-2134-11e6-b63c-6ce229284b01
openId openId can be used to uniquely identify the user (this field can be used as a custom unique key)
originalSiteUrl URL of the new site
removeFromCurrSite

Optional.

Default is false, and user will not be removed from the current (older) site.

Set to true, for removing user from current (older) site. Make sure to invoke this API on new site passed in originalSiteUrl

addToAutoEnrollGroups

Optional.

Default is false, and user will not be added to any "auto enroll groups" in new site.

Set to true, for adding the user to all "auto enroll groups" in new site. Make sure to invoke this API on new site passed in originalSiteUrl

 

Response

1. Response on successfully updating user's origin site

HTTP Response Code = HttpServletResponse.SC_OK

Response XML

<response code="0">
    <msgs>
         <msg>
             <code>0212</code>
             <value><![CDATA[Origin site updated successfully]]></value>
         </msg>
    </msgs>

</response>

 

2. Response on user not found

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>();
    populateMapForUserUpdate(parameters);
    parameters.put("dispatch", "changeOriginSite");

    parameters.put("originalSiteUrl", "a11.edubrite.com");
   
    String retStr = connection.invokeApi("userService.do", "chenry", parameters);
    System.out.println(retStr);

   


Rating: