Update Users

Updates a batch of existing users in an identity domain using an ANSI or UTF-8 encoded comma-separated value (CSV) file that was uploaded to the environment. Before using this API, use the Upload REST API to upload the file. Use double quotation marks to enclose fields that contain space charaters in the CSV file. The file should be deleted after the API executes. The file format is as follows:

Firt Name, Last Name,Email, User Login
Jane,Doe,<emailAddress>,jdoe
John,Doe,<emailAddress>,<emailAddress>

This API should be run only by Service Administrators who are also assigned to the Identity Domain Administrator role in the identity domain in which users are to be updated. The CSV file should not include the account of the user who executes this command. It updates all properties of the user identified by User Login. Because user accounts are common to all service environments that an Identity Domain Administrator supports, updating an account for one environment updates it for all environments that share the Identity Domain.

With this API, you can see which records failed and the reason why they failed in addition to how many records passed and failed.

The API is asynchronous and returns the Job ID. The presence of status -1 in the response indicates that the updating of users is in progress. Use the job status URI to determine whether the process is complete. Any non-zero status except -1 indicates failure.

This REST API is version v1.

Required Roles

Service Administrator and Identity Domain Administrator

Table 10-32 Tasks for Updating Users

Task Request REST Resource
Update users PUT /interop/rest/security/<api_verion>/users
Update users status GET /interop/rest/security/<api_version>/jobs/<jobId>

REST Resource

PUT /interop/rest/security/<api_verion>/users

Supported Media Types: application/x-www-form-urlencoded

Note:

Before using the REST resources, you must understand how to access the REST resources and other important concepts. See Implementation Best Practices for EPM Cloud REST APIs. Using this REST API requires prerequisites. See Prerequisites.

The following table summarizes the request parameters.

Table 10-33 Parameters

Name Description Type Required Default
api_version Specific API version Path Yes None
jobtype

UPDATE_USERS

Form Yes None
filename

The name of the uploaded ANSI or UTF-8 encoded CSV file containing the users to update, such as updateUsers.csv.

Form Yes None

Response

Supported Media Types: application/json

Table 10-34 Parameters

Name Description
details In the case of errors, details are published with the error string
status See Migration Status Codes
links Detailed information about the link
href Links to API call or status API
action The HTTP call type
rel Possible values: self or Job Status. If the value is set to Job Status, you can use the href to get the status
data Parameters as key value pairs passed in the request
items Details about the resource
links Details of the first URL to be requested to get the job details; rel is "Job Details"

Examples of Response Body in JSON format.

Example 1, when job is in progress

{
    "links": [
        {
            "rel": "self",
            "href": " https://<SERVICE_NAME>-
<TENANT_NAME>.<SERVICE_TYPE>.<dcX>.oraclecloud.com /interop/rest/security/<api_version>/users",
            "data": {
                "jobType": "UPDATE_USERS",
                "filename": "<filename>"
            },
            "action": "UPDATE"
        },
        {
            "rel": "Job Status",
            "href": " https://<SERVICE_NAME>-
<TENANT_NAME>.<SERVICE_TYPE>.<dcX>.oraclecloud.com /interop/rest/security/<api_version>/jobs/<jobID>",
            "data": null,
            "action": "GET"
        }
    ],
    "details": null,
    "status": -1,
    "items": null
}

Example 2, when job completes with errors:

{
"links": [
{
"rel": "self",
"href": "https://<SERVICE_NAME>-
<TENANT_NAME>.<SERVICE_TYPE>.<dcX>.oraclecloud.com/interop/rest/security/
<api_version>/jobs/",
"data": null,
"action": "GET"
}
],
"details": "Failed to update users. Input file <filename> not found. Specify a valid file name.",
"status": 1,
"items": null
}

Example 3, when job completes without errors:



{
"links": [
{
"rel": "self",
"href": "https://<SERVICE_NAME>-
<TENANT_NAME>.<SERVICE_TYPE>.<dcX>.oraclecloud.com/interop/rest/security/
<api_version>/jobs/",
"data": null,
"action": "GET"
}
],
"details": "Processed - 3, Succeeded - 2, Failed - 1.",
"status": 0,
"items": [
        {
            "UserName": "<username>",
            "Error_Details": " User <USER_NAME> not found. Verify that the user exists. "
        }
    ]}

Example 10-12 Java Sample Code

Prerequisites: json.jar

Common Functions: See: CSS Common Helper Functions for Java

	public void updateUsers(String fileName) {
		try {
			String url = this.serverUrl + "/interop/rest/security/" + apiVersion + "/users";
			Map<String, String> reqHeaders = new HashMap<String, String>();
			reqHeaders.put("Authorization", "Basic " + DatatypeConverter
					.printBase64Binary((this.userName + ":" + this.password).getBytes(Charset.defaultCharset())));

			Map<String, String> reqParams = new HashMap<String, String>();
			reqParams.put("filename", fileName);
			reqParams.put("jobtype", "UPDATE_USERS");

			Map<String, String> restResult = CSSRESTHelper.callRestApi(new HashMap(), url, reqHeaders, reqParams,
					"PUT");
			String jobStatus = CSSRESTHelper.getCSSRESTJobCompletionStatus(restResult, reqHeaders);
			System.out.println(jobStatus);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

Example 10-13 Shell Script Sample Code

Prerequisites: jq (http://stedolan.github.io/jq/download/linux64/jq)

Common Functions: See CSS Common Helper Functions for cURL

funcUpdateUsers() {
        url="$SERVER_URL/interop/rest/security/$API_VERSION/users"
        params="filename=$1&jobtype=UPDATE_USERS"
        header="Content-Type: application/x-www-form-urlencoded;charset=UTF-8"
        cssRESTAPI="UpdateUsers"
        statusMessage=$(funcCSSRESTHelper "PUT" "$url" "$header" "$USERNAME" "$PASSWORD" "$params" "$cssRESTAPI")
        echo $statusMessage
}

Example 10-14 Groovy Sample Code

Common Functions: See CSS Common Helper Functions for Groovy

def updateUsers(fileName) {

	String scenario = "Updating users from " + fileName ;
	String params = "jobtype=UPDATE_USERS&filename="+ fileName;
	def url = null;
	def response = null;
	try {
		url = new URL(serverUrl + "/interop/rest/security/" + apiVersion + "/users");
	} catch (MalformedURLException e) {
		println "Please enter a valid URL"
		System.exit(0);
	}
	response = executeRequest(url, "PUT", params, "application/x-www-form-urlencoded");
	if (response != null) {
		getJobStatus(getUrlFromResponse(scenario, response, "Job Status"), "GET");
	}
}
Common Functions