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

Use Testrail api via Python to get all test cases


I’ve been using the Testrail API (Python bindings) successfully for a week or more. However, I’m stumped on one API request:

GET index.php?/api/v2/get_cases/:project_id \

Python interpretation:
client.send_get(‘get_sections/1 \6’)

I’ve tried different formatting of the Python command to executing this api, but keep getting a similar error:
Traceback (most recent call last):
File “<pyshell#15>”, line 1, in
client.send_get(‘get_sections/1 \6’)
File “E:\Python\WinPython-32bit-\”, line 36, in send_get
return self.__send_request(‘GET’, uri, None)
File “E:\Python\WinPython-32bit-\”, line 86, in __send_request
(e.code, error))
testrail.APIError: TestRail API returned HTTP 400 (No additional error message received)

Can someone please give me some direction on this? Thanks.


Hello Del,

Thanks for your posting. The backslash (\) character in the example is considered a line break (to make the example more readable) and you wouldn’t include this in the actual API request.

If you want to filter for all cases in section 3 in suite 2 of project 1, you can simply specify this as follows:

GET index.php?/api/v2/get_cases/1&suite_id=2&section_id=3

Or as code:


The same behavior applies to get_sections:

Note that the suite ID is optional/ignored if your project uses the (default) single-suite mode with a single case repository.

I hope this helps!



Thanks for the clarity…


Sure, glad to help!