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

Python integration issue


Hi all,

I am new to python as well as Test rail . And i am trying to access the test rail thru API but i keep getting the following error . Any help would be highly appreciated .

Traceback (most recent call last):
File “C:/Users/saradhar/PycharmProjects/TestRailScripts/com/amazon/python/testRail/”, line 7, in
File “C:\Python\lib\”, line 36, in send_get
return self.__send_request(‘GET’, uri, None)
File “C:\Python\lib\”, line 76, in _send_request
result = json.loads(response.decode())
File "C:\Python\lib\json_init
.py", line 319, in loads
return _default_decoder.decode(s)
File “C:\Python\lib\json\”, line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File “C:\Python\lib\json\”, line 357, in raw_decode
raise JSONDecodeError(“Expecting value”, s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Process finished with exit code 1



Hi Saradha,

Thanks for your posting. Can you post the snippet how you call send_get, including API client initialization code (with passwords removed)? Can you please check the TestRail address you use?



Hi Tobias ,

Thanks for the quick reply. Here is the code snippet that i am using to send the request .

from testrail import *
import json
client = APIClient(‘https://servername/testrail’)


The url that i send is the same as the one that i give in the browser to connect to testrail.


Hi Saradha,

Thanks! Can you please double-check that the TestRail address is correct? Can you also check the response of TestRail in the _send_request method ( to see what’s actually returned (e.g. maybe an HTML page instead of JSON)?



Hi Tobias

Yeah i checked the _send_request method and the response is an html respone is as below :

b'<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">\n<html><head>\n<title>401 Unauthorized</title>\n</head><body>\n<h1>Unauthorized</h1>\n<p>This server could not verify that you\nare authorized to access the document\nrequested. Either you supplied the wrong\ncredentials (e.g., bad password), or your\nbrowser doesn\'t understand how to supply\nthe credentials required.</p>\n</body></html>\n'

But when the same password and user name i am giving in the browser i am able to login and perform all the actions.

Kindly help please.


Hi Saradha,

It looks like this is returned by your web server and not directly from TestRail. Do you/your IT/administrator have the option to review the web server logs? It seems that your web server does not pass the authentication details to TestRail but intercepts it and checks it on its own (which wouldn’t work of course). Can you/your IT please check this? Happy to help in case you have any questions.