API - Create User (With Custom Properties)

User Creation (With Custom Properties)

This API can be used to create one or more 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



Parameter 2 - UserName

Username of any site administrator


Parameter 3 - Request Parameters

Name Value
dispatch create
userName jdoe
firstName John
lastName Doe
email jdoe@edubrite.org
password userpassword (password is optional, if you plan to utilize SSO with any system, don't pass this parameter to create a user without any password in LMS. Such users can only login using SSO)
openId Optional - openId can be used to uniquely identify the user (this field can be used as a custom unique key)

Custom Properties are passed in following manner

customUpdPropMap['property name'] = value

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



1. Response on successfully creating user

HTTP Response Code = HttpServletResponse.SC_OK

Response XML

<response code="0">
             <value><![CDATA[User(s) added successfully.]]></value>

<!-- response also contains information of newly created user -->

<user id="4687042a-2155-11e6-b63c-6ce229284b01"
    siteRole="STUDENT" status="ACTIVE">
                    <value><![CDATA[4128 Business Center Drive]]></value>
                    <displayValue><![CDATA[4128 Business Center Drive]]></displayValue>
                    <groupMember groupId="3fa10542-60ef-11e5-9f32-02e883d7aedf"


2. Response on user creation error

HTTP Response Code = HttpServletResponse.SC_NOT_FOUND

Response XML

<response code="-1">
             <value><![CDATA[ serviceuser_0 serviceuser_1 already present. Please rename them]]></value>


3. Response for unauthorized access

HTTP Response Code = HttpServletResponse.SC_UNAUTHORIZED

Response XML

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


Code Snippet

    /*  Check API Call for detail generic code */
    Map<String, String> parameters = new HashMap<String, String>();
    parameters.put("dispatch", "create");
    String retStr = connection.invokeApi("userService.do", "chenry", parameters);

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