This vbscript gets the ticket and retrieves a list of all users.
Dim xDoc, objXML
'***http strings used for testing
httpStrLogin="http://gnhost.teradp.com/maple/do.ashx?cmd=login&name=administrator&pwd=adminpwd"
httpStrObjs="http://gnhost.teradp.com/maple/do.ashx?cmd=objs&ids=1718&ticket="
httpStrObjList="http://gnhost.teradp.com/maple/do.ashx?cmd=objsList&type=user&ticket="
'*****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
'***Try a simple objlist
Set objXML = CreateObject("MSXML2.XMLHTTP.3.0")
'open synchronous so we don't have to wait for the load
objXML.Open "GET", httpStrObjList & strTicket, false
objXML.Send
msgbox objXML.responseText
strResult= GetObjList(objXml.responseXML)
'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
'function to return the results of an objList cmd
'this function expects an xml in the form returned by the rest call: cmd=objslist&type=...
function GetObjList (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 & ":" & childNode.nodeType
if childNode.nodeName = "objsListResult" then
MsgBox "Result successful"
else
msgbox "Unknown result"
end if
else
GetObjList = "No child nodes."
end if
end function
This script should return the list of users in a message box similar to the one below.