# Execute a SQL SELECT query and return the result data with column metadata Executes a user-supplied SQL SELECT query and returns the result data along with column metadata. This endpoint does not save the report — it only runs the query and returns the results. The reportName is echoed back in the response for identification purposes. ## Endpoint **POST** `/dcapi/reports/queryReports/data` ## Request URL `https://{server-hostname}:8383/dcapi/reports/queryReports/data` ## Scope `QueryReport.CREATE` ## Header `Authorization: d92d4xxxxxxxxxxxxx15f52` ## Request Parameters ### Request Headers - **Content-Type** (`string`, Mandatory): `application/queryReport.v1+json` - **Accept** (`string`, Mandatory): `application/queryResult.v1+json` ### Request Body `application/json` - **reportName** (`string`, Mandatory): Name for the query report. Used for identification in the response and when saving. Allows word characters, hyphens, spaces, and non-Basic-Latin Unicode characters. Max 100 characters. - **query** (`string`, Mandatory): SQL SELECT query to execute. 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/data \ --header 'Accept: application/queryResult.v1+json' \ --header 'Authorization: d92d4xxxxxxxxxxxxx15f52' \ --header 'Content-Type: application/queryReport.v1+json' \ --data '{"reportName":"All technicians report","query":"select * from Table"}' ``` ### Sample Request Body Execute a SELECT query on the given table. ```json { "reportName": "All technicians report", "query": "select * from Table" } ``` ## Response Parameters ### HTTP Code 200 Response Body — `application/json` - **reportName** (`string`): The report name echoed back from the request for identification. - **data** (`JSON array`): Array of row objects where each key is a column name and each value is the column value as a string. - **columnDetails** (`JSON array`): Array of column metadata objects describing the result set columns including name and JDBC data type. ### HTTP Code 400 Response Body — `application/json` - **errorCode** (`string`): Error code identifying the failure reason. `INVALID_QUERY` = the SQL query is syntactically invalid or fails construction; `REP_NAME_EXISTS` = a query report with the same name already exists for this user. - **errorMessage** (`string`): Human-readable message describing the specific validation failure. ### HTTP Code 417 Response Body — `application/json` - **errorCode** (`string`): Error code for unauthorized MSP access. `REPORT_UNAUTHORIZED` = MSP non-admin user attempting to access query reports. - **errorMessage** (`string`): Human-readable message indicating the user is not authorized as an MSP admin. ### HTTP Code 500 Response Body — `application/json` - **errorCode** (`string`): Error code for server-side failure. `INTERNAL_ERROR` = an unexpected error occurred during query execution (e.g., SQLException). - **errorMessage** (`string`): Human-readable message describing the internal server error encountered during query execution. ## Possible Response Codes - `200` — HTTP code - `400` — HTTP code - `417` — HTTP code - `500` — HTTP code ## Sample Responses ### HTTP 200 Result of executing the given query. ```json { "reportName": "All Technician report", "data": [ { "user_id": "1", "last_name": "null", "description": "No Description", "middle_name": "null", "first_name": "admin", "createdtime": "1774255689700" }, { "user_id": "2", "last_name": "null", "description": "No Description", "middle_name": "null", "first_name": "guest", "createdtime": "1774255689700" } ], "columnDetails": [ { "columnDataType": -5, "columnName": "user_id" }, { "columnDataType": 12, "columnName": "first_name" }, { "columnDataType": 12, "columnName": "middle_name" }, { "columnDataType": 12, "columnName": "last_name" }, { "columnDataType": -5, "columnName": "createdtime" }, { "columnDataType": 12, "columnName": "description" } ] } ``` ### HTTP 400 SQL query is syntactically invalid or fails construction. ```json { "errorMessage": "Invalid query syntax or unsupported statement", "errorCode": "INVALID_QUERY" } ``` A query report with the same name already exists for this user. ```json { "errorMessage": "Report name already exists", "errorCode": "REP_NAME_EXISTS" } ``` ### HTTP 417 MSP non-admin user attempting to access query reports. ```json { "errorMessage": "You are not authorized to access this resource", "errorCode": "REPORT_UNAUTHORIZED" } ``` ### HTTP 500 Unexpected error during SQL query execution. ```json { "errorMessage": "An internal server error occurred while executing the query report", "errorCode": "INTERNAL_ERROR" } ``` ## 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.