Join 34,000+ subscribers and receive articles from our
blog about software quality, testing, QA and security.

[UI Script] Accessing TestRail's API via JavaScript


The following example accesses TestRail’s API via JavaScript. Requires session authentication support (can be enabled under Administration > Site Settings > API in TestRail).

Learn more about TestRail’s API and UI Scripts:

[code]name: Example API request
description: Demonstrates how to use the API via JavaScript
author: Gurock Software
version: 1.0
includes: ^suites/view

(document).ready( function() { .ajax(
url: uiscripts.env.page_base + ‘/api/v2/get_suite/’ +,
dataType: ‘json’,
beforeSend: function(xhr)
xhr.setRequestHeader(“Content-Type”, “application/json”);
xhr.setRequestHeader(“X-Requested-With”, “API Client”);
success: function(data, status)
console.log(data); // Contains the suite
error: function(error)


GET API Error - Response for preflight has invalid HTTP status code 400
Update test run description via UI script
Why is uiscripts.context.suite undefined while editing an existing suite?
Ability to use App object