Generate API
Endpoint
Endpoint:
/excel-ingestion/v1/data/generate/_initMethod: POST
Request Structure
Body Parameters:
RequestInfo: Object containing request information.
GenerateResource: Object containing the details of the resource to be generated.
type: unified-console
tenantId: Tenant identifier.
hierarchyType: Type of hierarchy.
referenceId: Reference identifier for the resource (e.g., campaign ID, project ID).
referenceType: Type of reference (e.g., campaign, project).
locale: Locale for the generated file
Request Example
{
"RequestInfo": {
"apiId": "Rainmaker",
"authToken": "{{authToken}}",
"userInfo": {
"id": 34602,
"uuid": "dd885ccb-f91d-4bf2-adb8-46fb66217797",
"userName": "CAPTAIN",
"name": "Ritik Verma",
"mobileNumber": "9437584392",
"emailId": "ritik.kumar@egovernments.org",
"locale": null,
"type": "EMPLOYEE",
"roles": [
{
"name": "Campaign Managers",
"code": "CAMPAIGN_MANAGER",
"tenantId": "dev"
}
],
"active": true,
"tenantId": "dev",
"permanentCity": null
},
"msgId": "1761036073664|en_IN",
"plainAccessRequest": {}
}
,
"GenerateResource": {
"tenantId": "dev",
"type": "unified-console",
"hierarchyType": "{{hierarchyType}}",
"referenceId": "{{referenceId}}",
"referenceType": "campaign",
"locale" : "en_IN"
}
}Response Structure
Success Response:
GenerateResource: Object containing the details of the generation request.
id: Unique identifier for the generation request (UUID).
tenantId: Tenant identifier.
type: unified-console
hierarchyType: Type of hierarchy.
referenceId: Reference identifier.
referenceType: Type of reference.
status: Current status of generation (pending, in_progress, completed, failed, expired).
locale: Locale for the generated file.
fileStoreId: File store identifier (populated when status is 'completed').
additionalDetails: Additional details including error information if failed.
errorCode: Error code if generation failed
errorMessage: Error message if generation failed
auditDetails : show the audit description
Flow
Client Initiates Request: The client sends a
generate/_initrequest to the Excel Ingestion service with the GenerateResource details.Validation of Request: The Excel Ingestion service validates the request schema and performs pre-generation validations:
Validates tenant ID
Validates resource type
Validates hierarchy type
Validates reference ID and reference type
Validates boundary data if present in additionalDetails
Validates locale
Expire Previous Records: Before starting generation, the service expires any previous completed records with the same
referenceId + typecombination by setting their status to 'expired'. This ensures only the latest generation is active.Generate Unique ID: Generate a unique UUID for the generation request.
Set Audit Details: Enrich the GenerateResource with audit details:
Set createdBy and lastModifiedBy from RequestInfo userInfo
Set createdTime and lastModifiedTime to current timestamp
Extract and set locale from RequestInfo if not provided
Persist Initial Record:
Set status to 'pending'
Persist the initial GenerateResource record to the database via Kafka (save topic)
This ensures the record is saved even in central instance deployments
Start Async Generation:
Start the actual Excel generation process in a background thread (using @Async)
Return immediately to the client with status 'pending' and HTTP 202 (ACCEPTED)
Async Processing:
The background thread calls
ExcelWorkflowService.generateAndUploadExcel()This performs the actual Excel file generation based on the type and configuration
The generated file is uploaded to filestore
Update Status:
Success Case:
Set status to 'completed'
Set fileStoreId with the uploaded file ID
Clear any error details from additionalDetails
Update lastModifiedTime and lastModifiedBy
Persist to database via Kafka (update topic)
Failure Case:
Set status to 'failed'
Set fileStoreId to null
Enrich additionalDetails with error information:
errorCode: Error code identifier
errorMessage: Human-readable error message
Update lastModifiedTime and lastModifiedBy
Persist to database via Kafka (update topic)
Flow Diagram
Status States
The generation process goes through the following status states:
pending: Initial state when the generation request is accepted. The Excel generation is queued for processing.
completed: The Excel file has been successfully generated and uploaded to filestore. The
fileStoreIdfield contains the file identifier.failed: The generation process encountered an error. Error details are available in
additionalDetails:errorCode: Identifier for the error typeerrorMessage: Human-readable error description
expired: Previous completed records are marked as expired when a new generation request is made for the same
referenceId + typecombination. This ensures only the latest generation is active.
Generation Configuration
Below is the MDMS configuration used during the generate/_init process. Based on the sheet name and generation class, the corresponding sheet is generated.
Error Handling
Errors during generation are captured and stored in the additionalDetails field:
Error Response Example:
Was this helpful?