cancel
Showing results for 
Search instead for 
Did you mean: 

Integration TestRail and TestComplete

SOLVED
Occasional Contributor

Integration TestRail and TestComplete

Hi, Is there anyone who has succesfully integrated the TestRail API into TestComplete?

 

I'm working with the VBScripts in TestComplete, but was not yet able to report my results back to TestRail using the TestRail API.

 

In fact, I'm not even getting close to getting the TestRail API working in my scripts.

 

Thanks in advance!

1 ACCEPTED SOLUTION

Accepted Solutions
Moderator

Re: Integration TestRail and TestComplete

I'm not a TestRails expert, but try passing the login/password in the Authorization header:

 

Dim o, user, password

user = "user" password = "password"
Set o = Sys.OleObject("MSXML2.XMLHTTP") o.open "GET","https://site.testrail.net/index.php?/api/v2/get_case/1", False o.setRequestHeader "Content-Type", "application/json" o.setRequestHeader "Authorization", "Basic " & Base64Encode(user & ":" & password) o.send Log.Message(o.status)

The code of the Base64Encode function is in this post on Stack Overflow.

 

UPD: fixed typos in the example


Helen Kosova
SmartBear Technical Writer
________________________
Vote up helpful replies.
Accept this reply if you think it's the best solution to your question.

View solution in original post

20 REPLIES 20
Community Hero

Re: Integration TestRail and TestComplete

Occasional Contributor

Re: Integration TestRail and TestComplete

Hi Marsha, 

 

Thanks for your reply. I already checked out that message post.

It did not bring any light into the problem ;-)

 

 

Community Hero

Re: Integration TestRail and TestComplete

Okay, can you show us some of your code?   What happens when you try the integration?

Occasional Contributor

Re: Integration TestRail and TestComplete

Hi Marsha,

 

This is the piece of code i tried to start with:

  Dim o
  Set o = CreateObject("MSXML2.XMLHTTP")
  o.open "GET","https://site.testrail.net/index.php?/api/v2/get_case/1",False,"user","password"
  o.setRequestHeader "Content-Type", "application/json" 
  o.send
  log.message(o.status)

The response is:

HTTP/1.1 401 Unauthorized
Content-Type: application/json; charset=utf-8
Date: Thu, 16 Jun 2016 06:45:46 GMT
Server: Apache
Set-Cookie: tr_rememberme=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; Max-Age=0
Content-Length: 87
Connection: keep-alive

{"error":"Authentication failed: invalid or missing user\/password or session cookie."}

I'm pretty sure the user/password is ok ;-)

 

Thanks for helping!

Community Hero

Re: Integration TestRail and TestComplete

Okay @TanyaGorbunova who is the TestRail expert?   Smiley Very Happy

Moderator

Re: Integration TestRail and TestComplete

I'm not a TestRails expert, but try passing the login/password in the Authorization header:

 

Dim o, user, password

user = "user" password = "password"
Set o = Sys.OleObject("MSXML2.XMLHTTP") o.open "GET","https://site.testrail.net/index.php?/api/v2/get_case/1", False o.setRequestHeader "Content-Type", "application/json" o.setRequestHeader "Authorization", "Basic " & Base64Encode(user & ":" & password) o.send Log.Message(o.status)

The code of the Base64Encode function is in this post on Stack Overflow.

 

UPD: fixed typos in the example


Helen Kosova
SmartBear Technical Writer
________________________
Vote up helpful replies.
Accept this reply if you think it's the best solution to your question.

View solution in original post

Occasional Contributor

Re: Integration TestRail and TestComplete

Hi Helen, 

 

The code snippet you sent is giving an VBScript error on 

 

Base64Encode(user + ":" password)

The base64Encode is expecting another type of variable.... (types don't match)

 

Thanks for helping!

 

 

Occasional Contributor

Re: Integration TestRail and TestComplete

Hi Helen, 

 

You brought me on the right track. He doesn't understand the "+", he needs a "&"

 

I got this working: 

 

Sub TRCom2()

Dim o, TCuser, TCpassword, TClogin, TCpassphrase

TCuser = "user"
TCpassword = "password"
TClogin = TCuser&":"&TCpassword
TCpassphrase = "Basic " & Base64Encode(TClogin)

Set o = CreateObject("MSXML2.XMLHTTP")
o.open "GET","https://site.testrail.net/index.php?/api/v2/get_case/1", False
o.setRequestHeader "Content-Type", "application/json" 
o.setRequestHeader "Authorization", TCpassphrase
o.send
Log.Message(o.status)

End sub

Thanks for your help. Now next step: getting things to read the JSON and POST stuf to TestRail....

Frequent Contributor

Re: Integration TestRail and TestComplete

I have log message as 200. Success. But the application is not opened. Please let me know how to proceed after that

With Regards
Vallalarasu Pandiyan | LinkedIn |Vallalarasu.p@gmail.com
New Here?
Join us and watch the welcome video:
Watch the new Interview
Top Kudoed Authors