Here is a simple script to log in. Substitute your server name, user and password in the string httpStrLogin.
Dim xDoc, objXML
'***http strings used for testing
httpStrLogin="http://gnhost.teradp.com/maple/do.ashx?cmd=login&name=administrator&pwd=adminpwd"
'*****Log in first and get the ticket
Set objXML = CreateObject("MSXML2.XMLHTTP.3.0")
'open synchronous so we don't have to wait for the load
objXML.Open "GET", httpStrLogin, false
objXML.Send
'retrieve the login ticket from the response xml
strTicket= GetLoginTicket (objXml.responseXML)
msgbox strTicket
'function to return the login ticket - needed for successive login to GN4
'this function expects an xml in the form returned by the rest call: cmd=login&name=...&pwd=...
function GetLoginTicket (xDoc)
'check that the xml is not empty
If xDoc.hasChildNodes Then
'find the result node by name
set resultNode = xDoc.selectSingleNode("//result")
'MsgBox "Found the node " & currNode.nodeName & " of type " & currNode.nodeType
Set childNode = resultNode.childNodes.Item(0)
'MsgBox childNode.nodeName & ":" & currNode.nodeType
if childNode.nodeName = "error" then
'MsgBox "Error logging in"
'retrieve the value of the attribute named 'message'
GetLoginTicket=childNode.getAttribute("message")
elseif childNode.nodeName = "loginResult" then
'MsgBox "Log in successful"
'retrieve the value of the attribute named 'ticket'
GetLoginTicket=childNode.getAttribute("ticket")
else
msgbox "Unknown result"
end if
else
GetLoginTicket = "No child nodes."
end if
end function
The result should display the login session ticket, similar to the one below, that is needed for successive REST calls for this session.