Report Library CSV file
You can export the content of the Report Library to a comma-seperated values (CSV) file based on the selected filter parameters. This article explains how to export a CSV file using the Perfecto Smart Reporting API.
For information on how to download the file directly from the Perfecto UI and for details on the resulting CSV file, see Export content to a CSV file.
Download report library data via API
A full code code sample is available on GitHub: CsvDownloadCodeSample.java
To download the CSV file via the API, you need to obtain a taskId
via the public API, request the CSV file by taskID
, and then retrieve the file per the download URL included in the query response.
The following code snippet shows all fields that can be sent in the JSON payload. For example requests, see step 1 in the procedure below.
JSON payload
{
"filter": {
"fields": {
"startExecutionTime": [<Unix time>],
"endExecutionTime": [<Unix time>],
"tags": [<one or more tags>],
"status": [<one or more statuses - PASSED, FAILED, BLOCKED, UNKNOWN>],
"os": [<one or more OS - ANDROID, BLACKBERRY, IOS, MAC, WINDOWS, LINUX>],
"browserType": [<one or more browser type - CHROME, FIREFOX, INTERNET_EXPORER, SAFARI, MICROSOFT_EDGE>],
"browserVersion": [<one or more browser version>],
"screenResolution": [<one or more screen resolution represented as <width>x<height>>],
"deviceType": [<one or more device type - MOBILE, DESKTOP, SIMULATOR>],
"deviceModel": [<one or more device model>],
"deviceId": [<one ore more device ID>],
"jobName": [<one or more CI Job Name>],
"jobNumber": [<one or more CI Job Number>],
"jobBranch": [<one or more CI job branch>],
"projectVersion": [<one or more project version>],
"projectName": [<one ore more project name>],
"failureReason": [<one or more failure reason IDs>],
"cleanException": [<one or more exception summary full texts>]
"triggerType":[<one or more trigger type - Manual, Scheduled, CI/CD>]
}
"excludeFields": {
"tags": [<one or more tags>],
"status": [<one or more statuses - PASSED, FAILED, BLOCKED, UNKNOWN>],
"os": [<one or more OS - ANDROID, BLACKBERRY, IOS, MAC, WINDOWS, LINUX>],
"browserType": [<one or more browser type - CHROME, FIREFOX, INTERNET_EXPORER, SAFARI, MICROSOFT_EDGE>],
"browserVersion": [<one or more browser version>],
"screenResolution": [<one or more screen resolution represented as <width>x<height>>],
"deviceType": [<one or more device type - MOBILE, DESKTOP, SIMULATOR>],
"deviceModel": [<one or more device model>],
"deviceId": [<one ore more device ID>],
"jobName": [<one or more CI Job Name>],
"jobNumber": [<one or more CI Job Number>],
"jobBranch": [<one or more CI job branch>],
"projectVersion": [<one or more project version>],
"projectName": [<one ore more project name>],
"failureReason": [<one or more failure reason IDs>],
"cleanException": [<one or more exception summary full texts>]
}
}
}
Expand a section to view details on the available parameters.
The following table lists some of the
{
"filter": {
"fields": {
"status": ["BLOCKED", "FAILED"],
"tags": ["tag1", "tag2"]
}
}
}
Name | Value | Description |
---|---|---|
startExecutionTime |
|
The start time, in milliseconds from midnight January 1, 1970 GMT - Epoch/Unix Time. If this parameter is set, Perfecto makes sure that the test start time is greater or equal to the startExecutionTime parameter. |
endExecutionTime |
|
The end time, in milliseconds from midnight January 1, 1970 - GMT Epoch/Unix Time. If this parameter is set, Perfecto makes sure that the test start time is less or equal to the endExecutionTime parameter. |
externalId |
|
Filters the data to show reports that match a specific driver execution. |
tags |
|
Filters the data to show reports that match a specific tag. To exclude a tag (or any other field), add it inside the |
status |
|
Filters the data to show reports that match a specific test status |
Id |
|
Filters the data to show reports that match a specific test ID |
executionId[0] or externalId |
|
Filters the data to show reports that match a specific execution ID |
os |
|
Filters the data to show reports that match a specific operating system |
browserType |
|
Filters the data to show reports that match a specific browser type |
browserVersion |
|
Filters the data to show reports that match a specific browser version. For example: Copy
|
screenResolution |
|
Filters the data to show reports that match a specific screen resolution. For example: Copy
|
deviceType |
|
Filters the data to show reports that match a specific device type |
deviceModel |
|
Filters the data to show reports that match a specific mobile device model. For example: Copy
|
deviceId |
|
Filters the data to show reports that match a specific device ID |
jobName |
|
Filters the data to show reports that match a specific job name |
jobNumber |
|
Filters the data to show reports that match a specific job number |
jobBranch |
|
Filters the data to show reports that match a specific job branch |
projectVersion |
|
Filters the data to show reports that match a specific project version |
projectName |
|
Filters the data to show reports that match a specific project name |
failureReason |
|
Filters the data to show reports that match a specific failure reason ID |
customField.FIELD_NAME |
|
Filters the data to show reports that match the value of a specific custom field. For example: Copy
|
cleanException |
|
Filters the data to show only reports that match the value of a specific clean exception, which is a cleaned-up version of the exception that occurred. To extract the code of the exception, Perfecto looks for specific strings in the stack trace. In the UI, this field is labeled Exception Summary. |
triggerType |
|
Filters the data to show reports that match a specific trigger type |
A request can combine any number of filter parameters (externalId, jobName, jobNumber) to achieve the filtered list.
Add the following header parameters to the request.
Name |
Value |
---|---|
Perfecto-Authorization |
<Your personal security token> |
To download the CSV file via API:
Headers
Add the following header parameters to all requests:
Name |
Value |
---|---|
Perfecto-Authorization |
<Your personal security token> |
-
Submit a request to generate the CSV report.
Method
Endpoint URL
POST
https://<reporting-server>/export/api/v3/test-executions/csv
The following code snippets show an example JSON body for the request to retrieve the
taskId
andstatus
. The sample request fetches tests filtered by different parameters.CopyExample filtering by job name, number, and branch as well as 2 tags{
"filter": {
"fields": {
"jobName": ["dev-e2e-tests"],
"jobNumber": ["1245"],
"jobBranch": ["master"],
"tags": ["retry-test", "nightly"]
}
}
}CopyExample filtering by start time, the statuses FAILED and BLOCKED, and the exclusion of 2 tags{
"filter": {
"fields": {
"startExecutionTime": [1641795055000],
"status": ["BLOCKED", "FAILED"]
},
"excludeFields": {
"tags": ["retry-test", "nightly"]
}
}
}The format of the response is a JSON structure with the following fields:
-
taskId
-
status
: EitherIN_PROGRESS
orCOMPLETE
-
url
: The final URL to download the CSV when it is ready
-
-
To retrieve the CSV report (download link) and status, append the generated taskId from step 1 to the API URL.
When the CSV file is ready, the API call returns the statusCOMPLETE
.Method
API
GET
https://<reporting-server>/export/api/v3/test-executions/csv/<taskId>
The following table specifies the required parameters.
Parameter name
Value
Description
taskId
<Task ID>
ID of the task that was returned by the initial API call
The format of the response is a JSON structure with the following fields:
taskId
status
: EitherIN_PROGRESS
orCOMPLETE
url
: The final URL to download the CSV file when it is ready
-
Download the CSV file from the URL specified in the
url
field of the response.