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.

Copy

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.

To download the CSV file via API:

Headers

Add the following header parameters to all requests:

Name

Value

Perfecto-Authorization

<Your personal security token>

  1. 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 and status. The sample request fetches tests filtered by different parameters.

    Copy
    Example 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"]
            }
        }
    }
    Copy
    Example 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: Either IN_PROGRESS or COMPLETE

    • url: The final URL to download the CSV when it is ready

  2. 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 status COMPLETE.

    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: Either IN_PROGRESS or COMPLETE
    • url: The final URL to download the CSV file when it is ready
  3. Download the CSV file from the URL specified in the url field of the response.