Back to QMetry All Products Help Page
How to import Results using REST APIs?
Working Sample
Please look at Sample projects and Code snippets 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 for your selected project.
2. Import test results
Import process is divided into 2 parts.
- Get Upload file URL
- Upload your test result file to generated URL
2.1 Get Upload file URL
URL : {{JIRA Base URL}}/rest/qtm/latest/automation/importresults
Method : POST
Notes
- zip file must contain files of same format given in the 'format' param.
- Request must be contains form-data, json raw body payload is not supported.
Authorization
This Automation REST API is protected by the same restrictions which are provided via JIRA. This means that you need to log in in JIRA to access this API.
To supply basic Auth header, you need to perform the following steps:
1. Build a string of the form username:password
2. Base64 encode the string Encode
3. Supply an "Authorization" header with 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 |
Request Parameters
Parameter | Type | Required | Description |
---|---|---|---|
apiKey | string | Yes | Your API Key. API Key is unique for a specific user in a single project. The result will be imported for the project associated with the given API Key. |
format | string | Yes | Format of result file to be imported. Supported formats:
|
testAssetHierarchy | string | No | Level of Hierarchy : Test Scenario-Test Case Or Test Case-Test Step |
testCaseUpdateLevel | number | No | Test Case update level while reusing test case, starts from 0 to 2. (This is only applicable when you use TestCase-TestStep Hierarchy option) 0 Append test steps while reusing Test Case. |
testRunName | string | No | Name of the test run to be created. Default value: Test Run |
platform | string | No | Name of Platform on which test run to be executed. |
labels | string | No | Comma separated names of Labels to be added to the test run. |
versions | string | No | Comma separated names of versions to be added to the test run. |
components | string | No | Comma separated names of Components to be added to the test run. |
sprint | string | No | Name of Sprint to be added to the test run. |
comment | string | No | Comment to be added to the test run. |
testRunKey | string | No | Provide Test Run key to append new results to existing Test Run. |
attachFile | boolean | No | Pass true for attachments upload in execution. Default value: false. |
JIRAFields | JSON | No | Check specific Automation custom fields possible value and format here. |
Responses
Response | Description |
---|---|
Pass | Returned if results file is uploaded successfully. The import process might take a while and you would be notified (by email or checking the status of the created test run) once the process completed. Example {
|
| Returned if any validation fails Example { |
Produces
application/json
3. View imported test results
Please refer to View Imported Test Results section to view imported test results.
4. JIRA Fields
i) How to get Custom Field ID?
Rest call to JIRA to get all JIRA fields.
The following URL gives all custom fields get ID for selected custom fields that you want to apply.
ii) Base format for custom fields.
[ { "testRun" : [ { } ] }, { "testScenario" : [ { } ] }, { "testCase" : [ { } ] } ] |
iii) Standard Custom Field Types
The following types are for reference only, other types of Custom Field Types are also supported.
Custom Field Type | Validation Rule | Example |
---|---|---|
Checkboxes | The checkbox accepts comma separated multiple values | { "customfield_10200": [ { "value": "true" }, { "value": "false" } ] } |
Date Picker | The Date picker accepts only specified format Date | { "customfield_10202":"2017-09-06" } |
Date Time Picker | The Date time picker accepts only specified format Date and time | { "customfield_10203": "2013-03-01T00:00:00.000+0400" } |
Number Field | The Number field accepts any number with decimal | { "customfield_10205": 2876784 } |
Radio Buttons | The radio button accepts single value from JIRA fields | { "customfield_10206": { "value": "option1" } } |
Select List (multiple choices) | The Select List Multiple accepts comma separated multiple values | { "customfield_10208": [ { "value": "Select List Multiple 1" }, { "value": "Select List Multiple 2" } ] } |
Select List (single choice) | The radio button accepts single value from JIRA fields | { "customfield_10209": { "value": "Select List single 1" } } |
Text Field (multi-line) | It accepts text in multiple lines | { "customfield_10210": "this is sample.\nexample" } |
Text Field (single line) | It accepts text in single line | { "customfield_10211": "this is sample.example" } |
URL Field | It accepts Web URL | { "customfield_10212": "http://www.url-encode-decode.com/" } |
User Picker (single user) | The User field accepts only available JIRA users | { "customfield_10213": { "name": "admin" } } |
iv) JSON Example
If you want to set 2 custom fields (checkbox, single text) on test run issue type and one custom fields (Radio Button) on scenario and test case level.
"JIRAFields" : [ { "testRun" : [ { "customfield_10200" : [ { "value" : "true" }, { "value" : "false" } ] }, { "customfield_10211" : "this is sample.example" } ] }, { "testScenario" : [ { "customfield_10206" : { "value" : "option1" } } ] }, { "testCase" : [ { "customfield_10206" : { "value" : "option1" } } ] } ] |
Back to QMetry All Products Help Page