LiquidPlanner Classic Forum

Ask a Question
Back to All

Cannot Authorize with VBA

Posted on behalf of jay bazile. Original posting date 2015-10-20.

I have the following VBA and I keep getting a 401 error. Username and password are correct. When I paste the url directly in the browser while logged in it works.

Sub GetData()

Dim arrData() As Byte
arrData = StrConv("xxxxxxx:xxxxxx", vbFromUnicode)

Dim objXML As MSXML2.DOMDocument
Dim objNode As MSXML2.IXMLDOMElement

Set objXML = New MSXML2.DOMDocument
Set objNode = objXML.createElement("b64")

objNode.DataType = "bin.base64"
objNode.nodeTypedValue = arrData
EncodeBase64 = objNode.Text

Set objNode = Nothing
Set objXML = Nothing


TargetURL = https://app.liquidplanner.com/api/workspaces/xxxxxx
Set HTTPReq = CreateObject("WinHttp.WinHttpRequest.5.1")

Header = "Basic " & EncodeBase64

 

HTTPReq.Open "GET", TargetURL, False
HTTPReq.setRequestHeader "Authorization", Header
HTTPReq.send
MsgBox (HTTPReq.ResponseText)

End Sub