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

[API] POST requests very slow



I am facing POST requests issues when trying to add case through the API.
This behaviour is quite recent and only impacts add_case as far as I have tested (Posting results still works well and fast for instance)
It takes now approximatively 60 seconds to succeed while it took 1 second few days ago, and sometimes it raises a 504 GATEWAY TIMEOUT error (> 60 seconds).

Am I missing something ?

Here is an example using requests in Python 2.7:

In [1]: import json
In [2]: import os
In [3]: import requests
In [4]: url = ''
In [5]: data = {'title': "test_add_case_api_testrail"}
In [6]: header = {"Content-Type": "application/json"}
In [7]: login = os.environ['TESTRAIL_LOGIN']
In [8]: key = os.environ['TESTRAIL_KEY']
In [9]: ret =
                      auth=(login, key),
In [10]: print ret
<Response [504]>

Which is weird is that the test is well created on the UI.



Hello Matthieu,

Thanks for your post! I believe we answered this via email already, but just in case you haven’t seen that yet: The issue is likely that you have a large amount of open/active test runs (likely added and used for automation), and this would cause performance issues when adding test cases via the UI or via the API as well. When a test case is created, TestRail would check all active test runs to see if the runs are configured to ‘Include all test cases’ or not, and if so it needs to add the test case as a test to the run. So with many open/active test runs, you can run into issues with lengthy test case creation times. We would recommend closing/purging any older inactive automation test runs that you no longer need to help mitigate this issue. You can also look into using the same test run for your automation, and keeping this open/active longer (just adding new results to the same test run) to help manage this as well. Hope this helps!



Hello Marco,

Thanks for your help, reducing the amount of open test runs solved my issue indeed.