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

Get the HTTP response status


I want get check if the response is 200.

I currently have the following function:

def get_test_run(project_id):
            Close test runs
        """"project_id: %s" % project_id)
        http_response = client.send_get('get_runs/%s' % project_id)

        return http_response.status_code

But .status_code doesnt seem to work, Any idea what I’m doing wrong?



i do not know how to check the response code, but you send a get, so this means your result is the json of that call. Ergo, if you have a valid json, the call was successful - does this way help you ?


Hi bygones,

Thanks for your quick reply.

Yes I could check the content of the response body, that would be fine.

I just thought I could do it with response code because the codes are outlined on this page:

200 Success, the test runs are returned as part of the response
400 Invalid or unknown project
403 No access to the project

But it seems I cant use them. But I guess I’ll just use the body of the response.

Thanks again


Hello por1,

I suppose that you’re using python. Are you using requests module to make calls to the API? because for me status_code works very well with this code :

import requests
headers = {“Content-Type”: “application/json”}
r = requests.get(testrailURL+"/index.php?/api/v2/get_run/674",auth=(testrailUser,testrailPassword),headers=headers,verify=False)
print r.text
print r.status_code

what are you getting if you put a print http_response.status_code before the return ?


This is exactly what I’m looking for! thank ye both for yer help!