API - Rename User

User Rename

This API can be used to rename user (change username) in the microsite. 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 renameUser
userName (new username) and either id or openId 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)

 

Response

1. Response on successfully updating user

HTTP Response Code = HttpServletResponse.SC_OK

Response XML

<response code="0">
    <msgs>
         <msg>
             <code>0172</code>
             <value><![CDATA[User 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", "renameUser");
   
    String retStr = connection.invokeApi("userService.do", "chenry", parameters);
    System.out.println(retStr);

    private void populateMapForUserUpdate(Map<String, String> parameters) {
           parameters.put("userName", "jdoenew");
           parameters.put("id", "xxx-xxx-xxx-xxx");
}

 

 


Rating: