# Run a predefined report

`GET /lokta-lms/api/v1/runreports/{reportName}`

This resource allows you to run and receive output from pre-defined Lokta reports.

Reports can also be used to provide data for searching and workflow functionality.

The default output is a JSON formatted "Generic Resultset". The Generic Resultset contains Column Heading as well as Data information. However, you can export to CSV format by simply adding "&exportCSV=true" to the end of your URL.

If Pentaho reports have been pre-defined, they can also be run through this resource. Pentaho reports can return HTML, PDF or CSV formats.

The Lokta reference application uses a JQuery plugin called stretchy reporting which, itself, uses this reports resource to provide a pretty flexible reporting User Interface (UI).



Example Requests:

runreports/Client%20Listing?R_officeId=1


runreports/Client%20Listing?R_officeId=1&exportCSV=true


runreports/OfficeIdSelectOne?R_officeId=1&parameterType=true


runreports/OfficeIdSelectOne?R_officeId=1&parameterType=true&exportCSV=true


runreports/Expected%20Payments%20By%20Date%20-%20Formatted?R_endDate=2013-04-30&R_loanOfficerId=-1&R_officeId=1&R_startDate=2013-04-16&output-type=HTML&R_officeId=1


runreports/Expected%20Payments%20By%20Date%20-%20Formatted?R_endDate=2013-04-30&R_loanOfficerId=-1&R_officeId=1&R_startDate=2013-04-16&output-type=XLS&R_officeId=1


runreports/Expected%20Payments%20By%20Date%20-%20Formatted?R_endDate=2013-04-30&R_loanOfficerId=-1&R_officeId=1&R_startDate=2013-04-16&output-type=CSV&R_officeId=1


runreports/Expected%20Payments%20By%20Date%20-%20Formatted?R_endDate=2013-04-30&R_loanOfficerId=-1&R_officeId=1&R_startDate=2013-04-16&output-type=PDF&R_officeId=1

**Available Parameters (All Optional):**

**Common Control Parameters:**
- `exportCSV`: Set to true to export results as CSV (default: false)
- `parameterType`: Indicates if this is a parameter type request (default: false)
- `output-type`: Output format type (HTML, XLS, CSV, PDF)
- `enable-business-date`: Enable business date filtering
- `obligDateType`: Obligation date type
- `decimalChoice`: Decimal formatting choice
- `Portfolio at Risk by Branch`: Portfolio risk parameter

**Common Report Parameters (R_ prefixed):**
- `R_officeId`: Office ID filter
- `R_loanOfficerId`: Loan officer ID filter
- `R_currencyId`: Currency ID filter
- `R_fromDate`, `R_toDate`: Date range filters (yyyy-MM-dd)
- `R_accountNo`: Account number filter
- `R_transactionId`: Transaction ID filter
- `R_centerId`: Center ID filter
- `R_branch`: Branch filter
- `R_ondate`: Specific date filter
- `R_cycleX`, `R_cycleY`: Cycle filters
- `R_fromX`, `R_toY`: Range filters
- `R_overdueX`, `R_overdueY`: Overdue filters
- `R_endDate`: End date filter

**Other Common Parameters:**
- `OfficeId`: Office ID filter (alternative)
- `loanOfficerId`: Loan officer ID filter (alternative)
- `currencyId`: Currency ID filter (alternative)
- `fundId`: Fund ID filter
- `loanProductId`: Loan product ID filter
- `loanPurposeId`: Loan purpose ID filter
- `parType`: Portfolio at risk type
- `SelectGLAccountNO`: GL account number selection
- `SavingsAccountSubStatus`: Savings account status
- `SelectLoanType`: Loan type selection

**Note:** All parameters are optional and report-specific. 
The exact parameters required depend on the specific report being executed.
Some reports may accept additional parameters not listed here.

## Parameters
- `reportName` (path, string, required): The name of the report to execute (e.g., 'Client Listing', 'Expected Payments By Date')
- `exportCSV` (query, boolean): Set to true to export results as CSV
- `parameterType` (query, boolean): Indicates if this is a parameter type request
- `output-type` (query, string): Output format type (HTML, XLS, CSV, PDF)
- `R_officeId` (query, string): Office ID filter
- `R_loanOfficerId` (query, string): Loan officer ID filter
- `R_fromDate` (query, string): Start date filter (yyyy-MM-dd)
- `R_toDate` (query, string): End date filter (yyyy-MM-dd)
- `R_currencyId` (query, string): Currency ID filter
- `R_accountNo` (query, string): Account number filter

## Responses
- `200`: OK - Report executed successfully
- `400`: Bad Request - Missing or invalid parameters
- `401`: Unauthorized - Not authorized to run this report
- `500`: Internal Server Error

## Response fields
- `columnHeaders` (array of ResultsetColumnHeaderData)
- `data` (array of ResultsetRowData)

## Example request (cURL)
```bash
curl -X GET \
  'http://localhost:8080/lokta-lms/api/v1/runreports/{reportName}' \
  -u '{username}:{password}' \
  -H 'Tenant-Identifier: default'
```

## Example response
```json
{
  "columnHeaders": [
    {}
  ],
  "data": [
    {}
  ]
}
```

Interactive: https://developer.lokta.ai/reference.html#operation/runReport
