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

Getting email address of user connected via API



We are replacing an in house database with testrail and have some functionality that currently pulls the email address from the logged in user’s LDAP/AD information that was stored in the database at login.

In TestRail I can’t figure out how to get the user id of the user connected via the API so that I can grab the email address - i can get the login name string from the client object but the login name isn’t associated with the user entry in testrail as far as I can determine (other than they are mapped in LDAP/AD).

I’d prefer not to have to do a second LDAP lookup from my code if at all possible.

Any help or guidance would be appreciated.




Hi John,

Thanks for your posting! There’s currently no direct API method for this and I would recommend doing an LDAP lookup, even if that’s not your preferred option. There’s a workaround to find out the user and user ID but this would require adding a result, case, or other object and then looking at the returned created_by/user_id field as part of the response. This returns the ID of the API user and you can then use get_users to look up the corresponding email address.



Thanks Tobias

Our security policy requires test systems be in a separate domain which has limited access to the corporate domain. Every system would now need permission to do an LDAP lookup or I’d need to create a proxy to do the lookup when TestRail already has access and each system must have access to TestRail.

I’ll investigate the workaround as I typically need email after saving results but I would request an addition to the APIClient to add a getUserId() method - this should be trivial as TestRail uses the Id for object creation so it must store it in the connection code somewhere!!!




Hi John,

We will make sure to look into this and I added a feature request for this. I hope the workaround is an option for you in the meantime and this would certainly be the easiest way compared to an LDAP lookup.