Loading Audio...
Importing and Exporting Clarity's Bulk Data
Batch engine APIs provide a high-performance approach to interacting with large data sets. Clarity’s developers want to test importing and exporting with batch APIs to understand how they can interact with their object data and populate dashboards with historic data sets.
In these exercises, you’ll export and import Clarity’s object entries with JSON data and batch API endpoints.
Exercise: Exporting Clarity’s Existing Tickets
Here, you’ll leverage the export-task endpoint to create a batch export of Clarity’s existing Ticket object entries.
-
Sign in as the Clarity Admin user.
- Username:
admin@clarityvisionsolutions.com - Password:
learn
- Username:
-
Navigate to the API Explorer at http://localhost:8080/o/api.
-
In the upper right, click the REST Applications drop-down menu and select
headless-batch-engine/v1.0. -
Under the ExportTask section, expand the
postExportTaskendpoint.
-
Enter these parameters and click Execute:
Parameter Value className com.liferay.object.rest.dto.v1_0.ObjectEntry contentType JSON batchNestedFields permissions fieldNames description,priority,resolution,subject,suggestions,ticketStatus,typetaskItemDelegateName C_Ticket NOTE
To import object entries, use the object definition as the value for the taskItemDelegateName property. The value’s format should beC_ObjectName, whereC_is a prefix followed by the object’s name (case-sensitive). -
Verify in the Response body that the batch process was submitted:
If the{ "className": "com.liferay.object.rest.dto.v1_0.ObjectEntry", "contentType": "JSON", "errorMessage": "", "executeStatus": "STARTED", "externalReferenceCode": "70fbff63-fab4-fafe-71d0-33fc0862cfcd", "id": 6, "processedItemsCount": 0, "startTime": "2025-05-20T20:58:31Z", "totalItemsCount": 0 }executeStatusisSTARTED, the batch engine task was submitted. -
Copy the ERC (
externalReferenceCode) value for a future step.
In this case,70fbff63-fab4-fafe-71d0-33fc0862cfcd. -
Within the Headless Batch Engine API, expand the
getExportTaskByExternalReferenceCodeendpoint. -
Paste in the previously copied ERC to the
externalReferenceCodeparameter and click Execute. -
Verify that the batch job now lists
COMPLETEDfor theexecuteStatus:
Large batch jobs can include thousands of data entries and take longer to complete. You can use this endpoint to check in on a batch job’s progress while it’s being processed.{ "className": "com.liferay.object.rest.dto.v1_0.ObjectEntry", "contentType": "JSON", "endTime": "2025-05-20T20:58:31Z", "errorMessage": "", "executeStatus": "COMPLETED", "externalReferenceCode": "70fbff63-fab4-fafe-71d0-33fc0862cfcd", "id": 6, "processedItemsCount": 6, "startTime": "2025-05-20T20:58:31Z", "totalItemsCount": 6 } -
Within the Headless Batch Engine API, expand the
getExportTaskByExternalReferenceCodeContentendpoint. -
Enter the same previously copied
externalReferenceCodeand click Execute.
-
Verify that the request's status code is 200 and the Response body includes a “Download file” link.
The downloaded file contains a JSON array containing all of Clarity’s existing Ticket entries, including only the filtered fields specified within the batch export job.
Exercise: Importing Clarity’s New Ticket Object Entries
While you can create import jobs with the Headless Batch Engine API’s import-task endpoints, Clarity would like to test leveraging the Ticket object’s dedicated batch endpoint to import some historic data records. Here, you’ll create a batch import to populate additional ticket object entries.
-
Navigate to the API Explorer at http://localhost:8080/o/api.
-
In the upper right, click the REST Applications drop-down menu and select
c/tickets. -
Under the Ticket section, expand the
postTicketBatchendpoint. -
Replace the placeholder curly brackets in the Request body with two square brackets.
This prepares your payload to include a JSON array. -
In your course workspace, open the
exercises/module-3/historic_ticket_data.jsonfile and copy its contents. -
In API Explorer, paste the JSON contents between the square brackets and click Execute.
-
Examine the Request body to verify that the import started:
The executeStatus of STARTED indicates that the batch job has started.{ "className": "com.liferay.object.rest.dto.v1_0.ObjectEntry", "contentType": "JSON", "errorMessage": "", "executeStatus": "STARTED", "externalReferenceCode": "5bd670b5-4780-d269-263a-2be27d6a620c", "failedItems": [], "id": 2603, "importStrategy": "ON_ERROR_FAIL", "operation": "CREATE", "processedItemsCount": 0, "totalItemsCount": 10 } -
From the Response body, copy the job’s
externalReferenceCode. -
In the upper right, click the REST Applications drop-down menu and select
headless-batch-engine/v1.0. -
Under the ImportTask section, expand the
getImportTaskByExternalReferenceCodeendpoint. -
Paste the copied
externalReferenceCodeand click Execute.
-
Verify that the Response body lists COMPLETED with 10 total items imported:
NOTE
If theexecuteStatusshowsFAILED, check theerrorMessagefield to understand what issue was encountered. -
Navigate to the Clarity home page.
-
Open the Site Menu (
), click Page Tree, and navigate to the Tickets page.
You should see 10 additional tickets included on Clarity’s dashboard, including historic, closed tickets.
Conclusion
Excellent! You’ve successfully leveraged dedicated batch APIs to export batch data from Liferay and import a set of object entries. You’ve explored both the dedicated batch engine endpoints and an entity-specific batch endpoint. This provides the foundation to migrate large data sets within your Liferay environment using APIs.
Next, you’ll review what you've learned before completing the course.
Capabilities
Product
Education
Knowledge Base
Contact Us