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

Unable to authenticate TestRail for using APIs

#1

Hi,
Our TestRail installation uses external authentication. I am trying to send a HTTP GET request to TestRail with basic authentication(username as my LDAP id,e.g. trevor and password as my LDAP password,e.g. test1234). However every time, I am getting 401 unauthorized error after sending this request. Can you please help me to solve this authentication problem?

Python code:
import requests
r = requests.get(url=‘https://(My TestRail server name)/testrail/index.php?/api/v2/get_plans/(My TestRail project id)’, auth=(‘trevor’, ‘test1234’), headers={‘Content-Type’: ‘application/json’})
print (r.status_code, r.reason)

Output:
(401, ‘Unauthorized’)

[AuthException] Authentication failed: invalid or missing user/password or session cookie.

0 Likes

#2

Hi Swapnil,

When using TestRail with LDAP auth it is not possible to use your login password as this is not stored in the TestRail database nor does LDAP auth work with APIs. Instead you would need to use an API key which can be generated under My Settings. Be sure to click “save” after generating and copying the key.

http://docs.gurock.com/testrail-api2/accessing#username_and_api_key

0 Likes