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

Api get_cases fails with 400 as suite_id is invalid

I can see the suite_id in the UI and have made sure that is the id which was sent as part of the get_cases API. But still the get_cases call fails with reason being invalid suite_id. Can someone help? I’m assuming that a project with multiple suites and thousands of tests need to specify the suite_id in order for the get_cases call to work. I’m also trying to use the limit and offset params.

Welcome to the forums…

Seeing what you were trying to call in the API would help but I will give the most likely answer.

In Test Rail the UI adds the C to the ID so that it would read something like C1. In the database the Case Id is 1 so when you use the API you would use 1 as the case id.

This above is the same for all UI in Test Rail. Run ID will be R1 in the UI but in the database the Run id = 1…

I have used the api for getting 1 case at a time and also to update the cases. So I’m familiar with dropping the leading char and besides imbusing the api to get the list of suites and using the id from there. Thanks for pointing it out though.

I will try to post the exact exception

the exception stack is posted below, your help is appreciated. the suite id is 38, proj id is 6 and limit is set to 250

(18:58 … testrailAPI) > python3 upTrCases.py
INFO:root:list_testcases args: 6, 38, 250, 0
Traceback (most recent call last):
File “upTrCases.py”, line 148, in
upTrCases_ut()
File “upTrCases.py”, line 144, in upTrCases_ut
trObj.batchProcessCases()
File “upTrCases.py”, line 65, in batchProcessCases
None, limit, offset)
File “…testrailAPI.py”, line 161, in list_testcases
return self._client.send_get(‘get_cases/’ + str(project_id) + ‘/&suite_id=’ + str(suite_id) + ‘/&limit=’ + str(limit) + ‘/&offset=’ + str(offset))
File “…testrailAPI.py”, line 42, in send_get
return self.__send_request(‘GET’, uri, filepath)
File “…testrailAPI.py”, line 91, in __send_request
raise APIError(‘TestRail API returned HTTP %s (%s)’ % (response.status_code, error))
testrailAPI.APIError: TestRail API returned HTTP 400 ({‘error’: ‘Field :suite_id is not a valid ID.’})