This example uses the Objs command to return object information. Be sure to pass a valid object id.
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=1725&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
'***Let's try an obj get - BE SURE TO USE A VALID objID
Set objXML = CreateObject("MSXML2.XMLHTTP.3.0")
httpStr = httpStrObjs & strTicket
'open synchronous so we don't have to wait for the load
objXML.Open "GET", httpStr, false
objXML.Send
msgbox objXML.responseText
strResult= GetObjs(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 objs cmd
'this function expects an xml in the form returned by the rest call: cmd=objs&ids=...
function GetObjs (xDoc)
'check that the xml is not empty
If xDoc.hasChildNodes Then
Set root = xDoc.documentElement
msgbox "This object is of type: " & root.nodeName
msgbox "The author is: " & root.getAttribute("author")
Set oNodeList = root.childNodes
msgbox "There are " & oNodeList.length & " child nodes."
set tNode = root.selectSingleNode("//title")
'MsgBox "Found the node " & tNode.nodeName & " of type " & tNode.nodeType
MsgBox "The title of this object is: " & tNode.nodeTypedValue
set tNode = root.selectSingleNode("//titlexx")
if tNode is nothing then MsgBox "there is no node named titlexx"
END if
end function
The script should return a message box containing the xml of an object similar to the one below.