API - Update User

User Update (With Custom Properties)

This API can be used to update users 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 update
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)
firstName John
lastName Doe
email jdoe@newcompany.org
timezone  timezone code string (PST, GMT, CST, EST, IST, NZST etc)

Custom Properties are passed in following manner

customUpdPropMap['property name'] = value

customUpdPropMap['address'] 4128 Business Center Drive
customUpdPropMap['department'] sales

 

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", "update");
   
    String retStr = connection.invokeApi("userService.do", "chenry", parameters);
    System.out.println(retStr);

    private void populateMapForUserUpdate(Map<String, String> parameters) {
           parameters.put("userName", "jdoe");
            parameters.put("firstName", "John");
            parameters.put("lastName", "Doe");
            parameters.put("email", "jdoe@edubrite.com");
            parameters.put("customUpdPropMap['address']", "4128 Business Center Drive");
            parameters.put("customUpdPropMap['dept']", "sales");
}

 

 


Rating: