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

TestRail Authentication Issues with VBA API


#1

I’m trying to access TestRail through a VBA script within Excel. I’ve seen that this has been done before by other users, but the documentation for this is minimal. I’ve attempted to recreate the code snippets I have seen and come up with this:

Function testAuthen(strURL As String)
Dim xmlConnect As New MSXML2.XMLHTTP60

Debug.Print ("URL: " & strURL)
Debug.Print ("Auth: Basic " & userPassBase64)

xmlConnect.Open “GET”, strURL, False
xmlConnect.setRequestHeader “Authorization”, “Basic " & userPassBase64
xmlConnect.setRequestHeader “Content-Type”, “application/json”
xmlConnect.send (”")

Debug.Print ("Output: " & xmlConnect.responseText)
Debug.Print ("Status: " & xmlConnect.Status)

End Function

Yet, when I run this I get an “Authentication failed” error. The curious thing is that I’ve done essentially the same thing in Python. The userPassBase64 function I am fairly confident is working correctly, as I output the encoded Authentication string and URL and they come back as exactly the same as what I’m getting in the Python script. Yet with Python, I connect with no issue. What am I missing here on the Excel side?