API: Test results

Note: you are looking at the old API documentation!

TestRail 3.0 introduced a new API which is now part of TestRail. This document describes the old API which is still supported but won't receive any new features. It is recommended to migrate any existing code to the new API.

Please also see the migration guide.

The following API methods are used to submit test results to TestRail. Please note the different approaches and methods to submit results.

get_results

Returns all results for a test.

Method:	get_results
HTTP:	GET
URL:	index.php?/miniapi/get_results/<test_id>&limit=<limit>
Result:	The results for the given test

get_results_for_case

Returns all results for a test (identified by the test run and test case IDs).

Method:	get_results
HTTP:	GET
URL:	index.php?/miniapi/get_results_for_case/<run_id>/<case_id>&limit=<limit>
Result:	The results for the given test run and test case

add_result

Use this method to add a result to a test, specified by its test ID.

Method:	add_result
HTTP:	POST
URL:	index.php?/miniapi/add_result/<test_id>
Result:	ID of the test change

Post arguments:

- status_id
   1 = Passed
   2 = Blocked
   4 = Retest
   5 = Failed
- comment
- version
- elapsed
- defects
- assignedto_id
- custom fields can be added with their system names, prefixed with 'custom_'

Steps custom fields

If you would like to submit the results for individual test steps to TestRail via the API, then you would need to specify the results in the following JSON format:

[
  {
    "status_id": 1,
    "content": "Step 1", 
    "expected": "Result 1",
    "actual": "Actual Result 1"
  },
  {
    "status_id": 5,
    "content": "Step 2",
    "expected": "Result 2",
    "actual": "Actual Result 2"
  }
]

You would send the above JSON snippet as the content of the steps custom field, e.g. custom_steps_separated.

add_result_for_case

Use this method to add a result to a test, specified by the test run and test case IDs. This alternative method is useful as the test case ID never changes. TestRail will automatically look up the test based on the specified test run and test case ID.

Method:	add_result_for_case
HTTP:	POST
URL:	index.php?/miniapi/add_result_for_case/<run_id>/<case_id>
Result:	ID of the test change

Post arguments:

- status_id
   1 = Passed
   2 = Blocked
   4 = Retest
   5 = Failed
- comment
- version
- elapsed
- defects
- assignedto_id
- custom fields can be added with their system names, prefixed with 'custom_'