vba XMLHTTP get xml from Content Server

628 views Asked by At

I'm trying to recover the XML from Content Server from Opentext using url. This is part of the code I'm using. wURL is : https://company.domain/company/cs.exe/?func=ll&objId=999999&objAction=xmlexport.

Set objXMLHTTP = CreateObject("MSXML2.XMLHTTP")
objXMLHTTP.Open "GET", wURL, False    
objXMLHTTP.Send 

xmldoc.Load objXMLHTTP.responseXML
Set xmlNodeList = xmldoc.getElementsByTagName("llnode")

I get this response :

?objXMLHTTP.responsetext = 
 <html><body onload="document.forms[0].submit()"><noscript><p><strong>Note:</strong> Since your 
 browser does not support JavaScript,you must press the Continue button once to proceed.</p>        
 </noscript><form action=wURL method="post"><div><input type="hidden" name="OTDSTicket" value="

I found out that if I go to the URL via IE prior to executing the function, it loads the XML just fine into xmlNodeList. I tried to automate the process with an IE object that navigate to the URL but it's not viable since I need to look through 500+ XML and eventually IE returns an automation error.

I think by going to the URL before I call my function, I somehow authenticate or create a connection and thus being able to load the XML. I would like to know if it is possible to recreate that authentication by code in a reliable way.

I also tried :

objXMLHTTP.Open "GET", wURL, False, myUserName, myPW 

with my credentials but it didn't change anything. Thank you.

2

There are 2 answers

1
Steffen Roller On

Which version are you on? You should try to use the rest api. Available with update 2014-09.

1
noodlesstillalive On
objXMLHTTP.setRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 1.1.4322; .NET CLR 3.5.30729; .NET CLR 3.0.30618; .NET4.0C; .NET4.0E; BCD2000; BCD2000)"

This tells the server you are IE8 (even though you aren't). Put it before the objXMLHTTP.Send line. Is this sufficient to trick the server?