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

Python integration issue


#1

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/importTestResults.py”, line 7, in
client.send_get(‘get_users’)
File “C:\Python\lib\testrail.py”, line 36, in send_get
return self.__send_request(‘GET’, uri, None)
File “C:\Python\lib\testrail.py”, 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\decoder.py”, line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File “C:\Python\lib\json\decoder.py”, 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

Thanks
Saradha


#2

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?

Cheers,
Tobias


#3

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’)
client.user='myemailid’
client.password=‘mypassword’

client.send_get(‘get_users’)

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


#4

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 (testrail.py) to see what’s actually returned (e.g. maybe an HTML page instead of JSON)?

Cheers,
Tobias


#5

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.


#6

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.

Cheers,
Tobias