# Execute a SQL SELECT query and export the result as a PDF or CSV file Executes a user-supplied SQL SELECT query and exports the result as a downloadable file in the requested format (PDF or CSV). This does not require a previously saved report — the SQL query and report name are provided directly in the request body. ## Endpoint **POST** `/dcapi/reports/queryReports/export` ## Request ### Request URL ```text https://{server-hostname}:8383/dcapi/reports/queryReports/export ``` ### Scope ```text QueryReport.CREATE ``` ### Header ```text Authorization: d92d4xxxxxxxxxxxxx15f52 ``` ### Request Parameters #### Request Headers - **Content-Type** `string` **Mandatory** - `application/queryReport.v1+json` - **Accept** `string` **Mandatory** - `application/octet-stream` #### Request Body `application/json` - `JSON object` - **reportName** `string` **Mandatory** - Name for the exported report file. Used as the download file name. Allows word characters, hyphens, spaces, and non-Basic-Latin Unicode characters. Min 1, max 100 characters - **query** `string` **Mandatory** - SQL SELECT query to execute for export. Only SELECT statements are allowed; DML, DDL, system catalog access (pg_, sys.), and injection patterns (xp_cmdshell, EXEC, WAITFOR, sp_) are blocked. Max 500,000 characters ### Sample Request ```curl curl --request POST \ --url https://appdomain/dcapi/reports/queryReports/export \ --header 'Accept: application/octet-stream' \ --header 'Authorization: d92d4xxxxxxxxxxxxx15f52' \ --header 'Content-Type: application/queryReport.v1+json' \ --data '{"reportName":"All Technician report","query":"select * from Table"}' ``` ### Sample Request Body Export a SELECT query result on the given table as a downloadable file ```json { "reportName": "All Technician report", "query": "select * from Table" } ``` ## Response ### Response Parameters #### HTTP Code 400 Response Body — `application/json` - `JSON object` - **errorCode** `string` - Error code for invalid export request. `INVALID_QUERY` = the SQL query is syntactically invalid, fails construction, or the requested export format is not supported (only pdf and csv are allowed) - **errorMessage** `string` - Human-readable message describing why the export request failed. Examples: Un-Supported format, Invalid query syntax #### HTTP Code 500 Response Body — `application/json` - `JSON object` - **errorCode** `string` - Error code for server-side failure. `INTERNAL_ERROR` = an unexpected error occurred during query execution or file generation (e.g., SQLException) - **errorMessage** `string` - Human-readable message describing the internal server error encountered during the ad-hoc export process ### Possible Response Codes - **200** HTTP code - **400** HTTP code - **500** HTTP code ### Sample Response: HTTP 200 ```text 200 OK ``` ### Sample Response: HTTP 400 Export format is not pdf or csv ```json { "errorMessage": "Un-Supported format", "errorCode": "INVALID_QUERY" } ``` SQL query is syntactically invalid or fails construction ```json { "errorMessage": "Invalid query syntax or unsupported statement", "errorCode": "INVALID_QUERY" } ``` ### Sample Response: HTTP 500 Unexpected error during query execution or file generation ```json { "errorMessage": "An internal server error occurred while exporting the query report", "errorCode": "INTERNAL_ERROR" } ``` ## API Rate Limit ![](https://www.zohowebstatic.com/sites/zweb/images/people/ico-help.png) **Duration:** 1 minute | **Threshold:** 30 | **Lock period:** 5 minutes Duration - Time window for the threshold. Threshold - Number of API calls allowed within the specified duration. Lock Period - Wait time before consecutive API requests.