test_runs_getTestRunTransactions
Retrieve detailed transaction information for a specific test run using the test run ID to analyze and optimize performance outcomes in LoadRunner Cloud.
Instructions
List all transaction information in a test run.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| runId | Yes | The ID of the test run. |
Implementation Reference
- The main handler function that executes the tool: authenticates using getAuthToken, constructs the API URL for test run transactions, appends query parameters, makes a GET request, handles errors, and parses the JSON response.const executeFunction = async ({ runId }) => { const baseUrl = process.env.LRC_BASE_URL; const tenantId = process.env.LRC_TENANT_ID; const token = await getAuthToken(); try { // Construct the URL with query parameters const url = new URL(`${baseUrl}/test-runs/${runId}/transactions`); url.searchParams.append('TENANTID', tenantId); url.searchParams.append('percentile', 90); url.searchParams.append('percentile', 95); // Set up headers for the request const headers = { 'Content-Type': 'application/json', 'Authorization': `Bearer ${token}` }; // Perform the fetch request const response = await fetch(url.toString(), { method: 'GET', headers }); // Check if the response was successful if (!response.ok) { const text = await response.text(); try { const errorData = JSON.parse(text); throw new Error(JSON.stringify(errorData)); } catch (jsonErr) { // Not JSON, log the raw text console.error('Non-JSON error response:', text); throw new Error(text); } } // Parse and return the response data const text = await response.text(); try { const data = JSON.parse(text); return data; } catch (jsonErr) { // Not JSON, log the raw text console.error('Non-JSON success response:', text); return { error: 'Received non-JSON response from API', raw: text }; } } catch (error) { console.error('Error retrieving test run transactions:', error); return { error: 'An error occurred while retrieving test run transactions.' }; } };
- Input schema definition for the tool, specifying the required 'runId' string parameter.name: 'test_runs_getTestRunTransactions', description: 'List all transaction information in a test run.', parameters: { type: 'object', properties: { runId: { type: 'string', description: 'The ID of the test run.' } }, required: ['runId'] } }
- tools/loadrunner-cloud/load-runner-cloud-api/test-runs-get-test-run-transactions.js:66-87 (registration)Tool registration object 'apiTool' that combines the handler function and schema definition, exported for dynamic discovery and loading in lib/tools.js.const apiTool = { function: executeFunction, definition: { type: 'function', function: { name: 'test_runs_getTestRunTransactions', description: 'List all transaction information in a test run.', parameters: { type: 'object', properties: { runId: { type: 'string', description: 'The ID of the test run.' } }, required: ['runId'] } } } }; export { apiTool };
- Import of the shared authentication helper function used by the handler.import { getAuthToken } from './auth-get-token.js';