This endpoint lets you upload a ZIP/TAR.GZ file with automated test results. Once the upload is successful, RTM creates a Test Execution issue with Test Case Executions for each test result.
Parameters | Description |
---|---|
projectKey (string, required) | The key of the RTM project used for importing the test results. |
file (file, required) | A ZIP/TAR.GZ file with the test results. Only ZIP/TAR.GZ files are supported, with a maximum size of 50 MB. |
reportType (string, required) | The format of the test results file. Accepted values are specific to the supported report types (e.g., JUNIT). |
jobUrl (string, required) | The URL of the CI job that executed the tests. It needs to start with http or https. |
name (string, optional) | A name used as summary for created Test Execution issue. |
treePath (string, optional) | A Folder path for created Test Execution. If path does not exists each folder will be created (e.g., /Automatic/e2e/moduleA). When empty then fallbacks to folder configured in RTM project configuration. |
testExecutionFields (string, optional) | A JSON string containing additional fields for the created Test Execution issue. Body compatible with the create issue REST API. |
testCaseFields (string, optional) | A JSON string containing additional fields for all created Test Cases issues. Body compatible with create issue REST API |
curl -X POST 'https://your-rtm-instance.com/api/v2/automation/import-test-results' \
-H 'Authorization: Bearer YOUR_API_TOKEN' \
-F 'projectKey=PROJECT_KEY' \
-F 'file=@/path/to/test-results.tar.gz' \
-F 'reportType=JUNIT' \
-F 'name=Example automated test execution'
-F 'treePath=/Automatic/e2e/moduleA'
-F 'jobUrl=https://ci.example.com/job/123' \
-F 'testExecutionFields={ "fields": {"labels" : ["e2etest"]} }' \
-F 'testCaseFields={"labels": ["automated", "regression"]}'
Access environment variables directly using process.env in Node.js without the dotenv package, as long as the environment variables are set before running the script.
Set environment variables when running your Node.js script:
RTM_API_TOKEN=your-api-token PROJECT_KEY=your-project-key RTM_URL=https://your-rtm-instance.com node script.js
If you’re using Node.js 20 or later, you can also use the –env-file flag to load variables from a .env file:
node --env-file=.env script.js
const fetch = require('node-fetch');
const FormData = require('form-data');
const fs = require('fs');
// Read environment variables
const RTM_API_TOKEN = process.env.RTM_API_TOKEN;
const PROJECT_KEY = process.env.PROJECT_KEY;
const RTM_URL = process.env.RTM_URL;
// Validate that required environment variables are set
if (!RTM_API_TOKEN || !PROJECT_KEY || !RTM_URL) {
console.error('Error: Missing required environment variables.');
process.exit(1);
}
// Create the FormData object
const form = new FormData();
form.append('projectKey', PROJECT_KEY);
form.append('file', fs.createReadStream('/path/to/test-results.tar.gz')); // Update with the actual path to your file
form.append('reportType', 'JUNIT');
form.append('jobUrl', 'https://ci.example.com/job/123');
form.append(
'testExecutionFields',
JSON.stringify({
fields: {
summary: 'Automated Test Execution',
description: 'Imported from CI',
},
})
);
form.append(
'testCaseFields',
JSON.stringify({
fields: {
labels: ['automated', 'regression'],
},
})
);
// Send the POST request using fetch
fetch(`${RTM_URL}/api/v2/automation/import-test-results`, {
method: 'POST',
headers: {
Authorization: `Bearer ${RTM_API_TOKEN}`, // Use the API token from environment variables
...form.getHeaders(), // Include headers from FormData
},
body: form, // Set the body to the FormData object
})
.then((response) => {
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status} - ${response.statusText}`);
}
return response.json(); // Parse the JSON response
})
.then((data) => {
console.log('Import Task ID:', data); // Log the response
})
.catch((error) => {
console.error('Error:', error.message);
});
If you’re using Node.js 20 or newer and want to load environment variables from a .env file:
RTM_API_TOKEN=your-api-token
PROJECT_KEY=your-project-key
RTM_URL=https://your-rtm-instance.com
node --env-file=.env script.js
If both an environment variable and a variable in the .env file have the same name, the environment variable takes precedence.
import requests
url = 'https://your-rtm-instance.com/api/v2/automation/import-test-results'
headers = {
'Authorization': 'Bearer YOUR_API_TOKEN'
}
files = {
'file': open('/path/to/test-results.zip', 'rb')
}
data = {
'projectKey': 'PROJECT_KEY',
'reportType': 'JUNIT',
'jobUrl': 'https://ci.example.com/job/123',
'testExecutionFields': '{"summary": "Automated Test Execution", "description": "Imported from CI"}',
'testCaseFields': '{"labels": ["automated", "regression"]}'
}
response = requests.post(url, headers=headers, files=files, data=data)
print('Import Task ID:', response.json())
This endpoint lets you check the status of an import task using the task ID obtained from the initial import request.
Parameters | Description |
---|---|
taskId (UUID, required) | The unique identifier of the import task. |
curl -X GET 'https://your-rtm-instance.com/api/v2/automation/import-status/{taskId}' \
-H 'Authorization: Bearer YOUR_API_TOKEN'
const taskId = 'your-task-id'; // Replace with your actual task ID
const apiUrl = `https://your-rtm-instance.com/api/v2/automation/import-status/${taskId}`; // Update the base URL if necessary
fetch(apiUrl, {
method: 'GET',
headers: {
Authorization: 'Bearer YOUR_API_TOKEN', // Replace with your actual API token
},
})
.then((response) => {
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
return response.json(); // Parse the JSON response
})
.then((data) => {
console.log('Import Status:', data); // Log the response data
})
.catch((error) => {
console.error('Error:', error.message);
});
import requests
task_id = 'your-task-id'
url = f'https://your-rtm-instance.com/api/v2/automation/import-status/{task_id}'
headers = {
'Authorization': 'Bearer YOUR_API_TOKEN'
}
response = requests.get(url, headers=headers)
print('Import Status:', response.json())
If you can’t find the answer you need in our documentation, raise a support request. Include as much information as possible to help our support team resolve your issue faster.