0

Im trying to set up a connection to the TestRail API within VBA for Excel but I keep getting this error

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

This is the HTTP request

userPass = user + ":" + pass

Dim TAuth As New MSXML2.XMLHTTP60

userPass = Base64Encode(userPass)
userPass = "Basic " + userPass

With TAuth
    .Open "POST", "https://testrail.<server>.com/index.php?/api/v2/get_case/3 HTTP/1.1", False
    .SetRequestHeader "Content-Type", "application/json"
    .SetRequestHeader "Accept", "application/json"
    .SetRequestHeader "Authorization", userPass
    .send
    sStatus = .Status
    sErg = .responseText

End With

Now I am using the correct username/password variables and the server address is accurate and Base64Encode() is working correctly.

Why am I recieving the Auth failed error?

unknownSPY
  • 706
  • 4
  • 15
  • 27
  • Have you tried: `.Open "POST", "https://testrail..com/index.php?/api/v2/get_case/3 HTTP/1.1", False, user, pass` without doing any encoding? See [Open method documentation](https://msdn.microsoft.com/en-us/library/ms757849(v=vs.85).aspx) – barrowc Jan 06 '16 at 00:30
  • 1
    Actually, not sure why the "HTTP:1/1" part is in the URL so try without that too – barrowc Jan 06 '16 at 00:56

0 Answers0