Import Results Using Rest API
Working Sample
Please look at Sample Projects for Automation sections for a more concrete end-to-end example.
1. Use API Key for Importing Results
Please Generate API Key if you don't have it for your selected project.
2. Import test results
The import process is divided into three sections:
Get Upload file URL: This API gets all required test automation details from the user and responds with a URL to upload the results.
Upload your test result file to the generated URL: This API is used to upload the automation results file and import test results.
Check Progress: This API is used to check the progress of automation result import.
2.1 Get Upload file URL
This API gets all required test automation details from the user and responds with a URL to upload the results.
URL : https://{{Jira base URL}}/rest/qtm4j/automation/latest/importresult
Method : POST
REQUEST HEADER :
Content-Type: application/json
apiKey: {generated-api-key}
Authorization: This Automation REST API is protected by the same restrictions that are provided through Jira. This means that you need to log in to Jira to access this API.
Option 1:
To supply a basic Auth header, perform the following steps:
Build a string of the form username:password
Password: Password refers to the API token generated from the API Token Authentication for Jira app.
How to generate API Token?
Install the API Token Authentication for Jira app in Jira.
Go to Administration and select User Management.
Locate the API Token Authentication option on the navigation bar and generate the API Token. Use this API Token as a password.
Encode the string in Base64 format.
Supply an Authorization header with the content Basic followed by the encoded string. For example, the string "fred:fred" encodes to "ZnJlZDpmcmVk" in base64, so you would make the request as follows.
Authorization:
Basic ZnJlZDpmcmVk
Option 2:
To use a personal access token, perform the following steps:
Go to User Profile.
Click Personal Access Tokens and click Create token.
Supply an "Authorization" header with the content "Bearer" followed by a generated token.
Authorization: Bearer NTE1NTYzMTg4MDEzOit5OlIjghTQQEH/YZ7HNrpSxvcU
Note
The zip file must contain files of the same format given in the format param.
Request must contain a JSON raw body payload; form-data is not supported.
Request Parameters
Parameter | Type | Required | Description | Default |
|---|---|---|---|---|
Format | string | Yes | Format of result file to be imported. Supported formats:
| NA |
testCycleToReuse | string | No | Issue Key of the test cycle to be reused. TestNG: Hierarchy 2: The testCycleToResue will be ignored. Hierarchy 3: If the testCycleToResue is provided, then the suite name in the files will be ignored. All the test case results for all suites and files will be uploaded in a single cycle similar to Hierarchy 1 (default). JUnit: Hierarchy 2: The testCycleToResue will be ignored. Hierarchy 3: If the testCycleToResue is provided, then test case results for all suites and files will be uploaded in a single cycle. | NA |
environment | string | No | Name of the environment on which the test cycle has to be executed | No Environment |
build | string | No | Name of the build for test cycle execution | Blank |
isZip | boolean | No (Yes for QAF) | Pass true for ZIP upload or pass false for single file upload | false |
attachFile | boolean | No | Pass true to upload attachments in execution. For more details, Refer to automation help documents. This parameter is supported only for-
| false |
fields | JSON | No | Provide additional fields to be added on a test case or test cycle level. Refer to the following table for more. Note
| NA |
matchTestSteps | boolean | No |
When the Test Cycle is not been Reused Create/Reuse a test case with a summary or test case key that exactly matches the automated test case uploaded through the result file, and exclude matching of test steps. The execution results of the test case will be imported or calculated based on the test case/step results from the automation result file. The execution result of the test case will be propagated to the test steps in the case of test case reuse/creation. Individual test case steps will not be matched and their execution results/details will not be picked from the result file. When the Test Cycle is been Reused When the Test Case Key is mapped in the result file and the Test Case Key is found linked to the Test Cycle. The existing linked test case version, which is part of the Test Cycle will be used. If multiple versions of the same test case key are linked to the test cycle, the one which traced first will be used. The test steps will not be matched to create a new version or link a different version. When the Test Case Key is mapped in the result file and the Test Case Key is not linked to the Test Cycle and the Test Case Key exists in the Test Case Library. The existing latest version of the test case that matches based on the test case summary will be linked to the existing Test Cycle. If there are multiple test cases with the same summary exist, the one which is traced first will be linked to the existing Test Cycle. The test steps will not be matched to create a new version or link a different version. In a project where propagation is off, the status of the step will not be mapped/changed. When the Test Case Key is mapped in the result file and the Test Case Key is not found linked to the Test Cycle and the Test Case Key is not found in the Test Case Library, and the Test Case Summary matches with any existing test cases linked to the Test Cycle. The existing linked Test Case version which is part of the Test Cycle will be used. The test steps will not be matched to create a new version. The Test Case Key is not mentioned in the result file and the Test Case Summary matches any existing test case that is already linked to the Test Cycle. The existing linked Test Case version which is part of the Test Cycle will be used based on the summary. The test steps will not be matched to create a new version. When the Test Case Key is mapped in the result file and the Test Case Key does not exist in the Test Cycle OR is Not found in Library and the Test Case Summary also does not match any existing Test case in the Test Cycle and Test Case with the same summary is found in the Test Case Library. The existing latest version of the test case that matches based on the test case summary will be linked to the existing Test Cycle. If there are multiple test cases with the same summary exist, the one that is traced first will be linked to the existing Test Cycle. The test steps will not be matched to create a new version or link a different version. When the Test Case Key is mapped in the result file and the Test Case Key does not exist in the Test Cycle OR is Not found in the Library and the Test Case Summary also does not match any existing Test case in the Test Cycle OR is not found in the Test Case Library. A new test case without steps will be created and will be linked to the Test Cycle being reused. The execution results of the test case will be imported or calculated based on the test case/step results from the automation result file. The execution result of the test case will be propagated to the test steps in the case of test case reuse/creation. Individual test case steps will not be matched and their execution results/details will not be picked from the result file. In a project where propagation is off, the status of the step will not be mapped or changed. | true |
appendTestName | boolean | No |
TestNG
JUnit
| As per Settings |
automationHierarchy | number | No |
Set Hierarchy for Automation Uploads “Test Cycle - Test Case - Test Step Hierarchy” as 1 (Default), 2 or 3 For TestNG
For JUnit
| As per Settings |
useFeatureName | boolean | No | Applicable to the Cucumber framework only. When enabled, the Feature name will be imported as the Test Case Component. NoteThis parameter is available starting from QMetry Test Management for Jira v4.13.1. | false |
useFeatureDescription | boolean | No | Applicable to the Cucumber framework only. When enabled, the Feature description will be imported as the Test Case Description. NoteThis parameter is available starting from QMetry Test Management for Jira v4.13.1. | false |
Note
If the Test Name or Test Suite Name length is more than 255 characters, the name will be truncated.
Supported Fields
Supported Fields | Type | Test Cycle | Test Case | Default | Comment |
|---|---|---|---|---|---|
labels | array | Yes | Yes | null | |
components | array | Yes | Yes | null | |
status | string | Yes | Yes | TO DO | |
priority | string | Yes | Yes | Medium | |
folderPath | string | Yes | Yes | null | |
fixVersionId | number | Yes | Yes | null | |
sprintId | number | Yes | Yes | null | |
summary | string | Yes | No | Automated Test Cycle | |
description | string | Yes | Yes | null | |
precondition | string | No | Yes | null | |
assignee | string | Yes | Yes | Account Key of current User | Valid User Account Key (Refer to Get account key of the user section below) Example: "JIRAUSER11801" |
reporter | string | Yes | Yes | Account Key of current User | Valid User Account Key (Refer to Get account key of the user section below) Example: "JIRAUSER11801" |
estimatedTime | string | No | Yes | null | Pass time in ‘HH:mm’ format |
plannedStartDate | string | Yes | No | null | Pass date in 'dd/MMM/yyyy HH:mm' format |
plannedEndDate | string | Yes | No | null | Pass date in 'dd/MMM/yyyy HH:mm' format |
customFields | array | Yes | Yes | null |
|
Get the account key of a User
Log in to your Jira Server instance.
Browse http://{BASE_URL}/rest/api/2/user/search?username={username}
You will get the userkey in the output.
Sample Request
{
"format": "cucumber",
"testCycleToReuse":"TR-PRJ-1",
"attachFile": true,
"isZip": false,
"environment": "Chrome",
"build": "4.1.0",
"matchTestSteps": true,
"useFeatureName":true,
"useFeatureDescription":true,
"fields": {
"testCycle": {
"labels": [
"label1",
"label2"
],
"components": [
"component1"
],
"priority": "High",
"status": "To Do",
"folderPath":"F1/F2/F3",
"summary": "Test Cycle Summary Automation with custom fields",
"description": "Test Cycle Automation Description",
"assignee": "JIRAUSER11801",
"reporter": "JIRAUSER11600",
"plannedStartDate": "20/May/2021 00:00",
"plannedEndDate": "30/May/2021 00:00",
"customFields": [{
"name": "Check Boxes",
"value": "MCB 1,MCB 2"
},
{
"name": "Date picker",
"value": "29/May/2021"
},
{
"name": "Date time picker",
"value": "29/May/2021 14:55"
},
{
"name": "Multi DropDown",
"value": "MDD 2,MDD 1"
},
{
"name": "Multi line text field",
"value": "QMetry Automation Testing using cucumber framework "
},
{
"name": "Number field",
"value": 1234567890
},
{
"name":"Cascade Drop down",
"value":"User Details", "cascadeValue": "Email"
},
{
"name": "Single DropDown",
"value": "DD2"
},
{
"name": "Single line Textbox",
"value": "QMetry Automation Testing using cucumber framework"
},
{
"name": "Custom Radio Button",
"value": "Test C"
},
{
"name":"Single User Picker",
"value":"JIRAUSER11600"
},
{
"name":"Multiple user picker field",
"value":"JIRAUSER11801,JIRAUSER11800,JIRAUSER11702"
},
{
"name":"Custom field type Label for Test Cycle",
"value":"TestLabel"
}
]
},
"testCase": {
"labels": [
"label1",
"label2"
],
"components": [
"component1"
],
"priority": "High",
"status": "To Do",
"folderPath":"F1/F2/F3",
"sprintId": "1000",
"fixVersionId": "10000",
"description": "Automated generated Test Case",
"precondition": "Precondition of Test Case",
"assignee": "JIRAUSER11702",
"reporter": "JIRAUSER11800",
"estimatedTime": "10:10",
"customFields": [{
"name": "Check Boxes",
"value": "MCB 1,MCB 2"
},
{
"name": "Date Picker",
"value": "29/May/2021"
},
{
"name": "Date Time Picker",
"value": "29/May/2021 14:55"
},
{
"name": "Multi DropDown",
"value": "MDD 2,MDD 1"
},
{
"name": "Multi line text field",
"value": "QMetry Automation Testing using cucumber framework "
},
{
"name": "Number field",
"value": 1234567890
},
{
"name":"Cascade Drop down",
"value":"User Details", "cascadeValue": "Email"
},
{
"name": "Single DropDown",
"value": "DD2"
},
{
"name": "Single Line Textbox",
"value": "QMetry Automation Testing using cucumber framework"
},
{
"name": "Radio Buttons",
"value": "Test C"
},
{
"name":"Single User Picker",
"value":"JIRAUSER11600"
},
{
"name":"Multiple User Picker",
"value":"JIRAUSER11801,JIRAUSER11800,JIRAUSER11702"
},
{
"name":"Custom Labels for Test Case",
"value":"TestLabel"
}
]
},
"testCaseExecution":{
"comment": "Test Case Execution Comment",
"actualTime": "10:10",
"executionPlannedDate": "16/Feb/2024",
"assignee": "{Valid User Account Key}"
"customFields": [
{
"name": "custom field 1",
"value": "high,medium,low"
},
{
"name": "custom field 2",
"value": 10.12
}
]
}
}
} Responses
Response | Description |
|---|---|
STATUS 200 | Returns if the results file is uploaded successfully. The import process might take a while and you are notified (by email or by checking the status of the created test run) once the process is completed. Example {
"format":"QAF",
"fileName":"1558945546874_840ba1e3-bf14-4f08-b19c-e5de6447711b.zip",
"processStatus":"VALIDATION/PARSING/CREATING_ASSETS/SUCCESS",
"importStatus":"SUCCESS/INPROCESS/FAILED",
"startTime":"2025-05-27T08:25:47.000+0000",
"endTime":null,
"fileSize":1500,
"trackingId":"840ba1e3-bf14-4f08-b19c-e5de6447711b",
"files":[]
} |
STATUS 400 | Returned if import fails If unsupported framework is sent in request {
"status":400,
"errorMessage":"Framework ‘xyz’ is not supported.",
"timestamp":"28/May/2025 04:58"
}If zip file is not sent in QAF framework request {
"status":400,
"errorMessage":"Zip file format is required for QAF framework.",
"timestamp":"28/May/2025 05:00"
} If one or more fields have invalid value {
"status":400,
"errorMessage": "The supplied fields are invalid",
"errors":[
"Provided Component Name(s) xyz not found ",
"Provided Label Name(s) xyz not found"
],
"timestamp":"29/May/2025 12:44"
} |
2.2 Upload test result file
This API is used to upload the automation results file and import test results.
URL: {{URL generated from step 1}}
Method: POST
Request Header
Content-Type:
multipart/form-dataapiKey: {generated-api-key}
Authorization: Basic
ZnJlZDpmcmVk
Request Body Binary: Your result file to be uploaded. Supported file extensions: .json, .xml, and .zip (zip file must contain files of the format given in the 'format' param).
Note
File Attachment must be passed in form-data.
Responses
Response | Description |
|---|---|
STATUS 204 | Returned if the file is uploaded successfully. |
2.3 See Progress
This API is used to check the progress of automation result import.
URL: https://{{Jira base url}}/rest/qmetry/automation/latest/importresult/track?trackingId={{trackingId from import result step}} Methood:GET
Content-Type:application/jsonapiKey:{generated-api-key}Authorization: Basic
ZnJlZDpmcmVk
Responses
Response | Description |
|---|---|
STATUS 200 | Returned if parameters are validated successfully. Example {
"format":"QAF",
"fileName":"1558945546874_840ba1e3-bf14-4f08-b19c-e5de6447711b.zip",
"processStatus":"VALIDATION/PARSING/CREATING_ASSETS/SUCCESS",
"importStatus":"SUCCESS/INPROCESS/FAILED",
"startTime":"2019-05-27T08:25:47.000+0000",
"endTime":null,
"fileSize":1500,
"trackingId":"840ba1e3-bf14-4f08-b19c-e5de6447711b",
"files":[]
}
|
STATUS 400 | Returned in invalid trackingId If trackingId is invalid Example {
"status":404,
"errorMessage":"No import details found for given tracking id '840ba1e3-bf14-4f08-b19c-e5de6447711b'",
"timestamp":"02/Apr/2020 16:19"
} |
3. View imported test results
Please refer to View Imported Test Results section to view imported test results.