I know vb6 is old, but I can quickly do what I need to do with the xml data in vb6 rather than learn a new lang. I just cannot get it to extract successfully from the required REST API sites.
In VB6, I've added the reference Microsoft XML 3 - 6 to try and see if it makes a difference, but it doesn't.
My code is really simple:
Dim sUrl As String
Dim xmlhttp As MSXML2.ServerXMLHTTP60
Set xmlhttp = New MSXML2.ServerXMLHTTP60
sUrl = "<url>"
xmlhttp.Open "GET", sUrl, False
xmlhttp.setRequestHeader "Content-Type", "application/xml"
xmlhttp.send ""
If xmlhttp.Status = 200 Then
Debug.Print xmlhttp.responseText
End If
Set xmlhttp = Nothing
I've tried changing the object ref to 'MSXML2.xmlhttp', 'XMLHTTP60', and 'MSXML2.ServerXMLHTTP', but still no difference.
Every time they either say System Error -2146697208 or access denied.
If I put the URL into a web browser and do view source then I see the xml text that I'm after.
I've even tried to run this all through a Classic ASP web page (I'm more familiar with this tech) and I still can't get this data down.
Does anybody know what the definitive code is to simply connect to a REST API site and bring it down as an xml text object??
Thanks
UPDATE 23-01-19
Hi All
Following on from Peter's comment, I've been trying to do this on my trusted Win XP SP3 machine and it wouldn't have it. I've just tried the below on a local ASP classic site on a Win 10 Pro machine and it works:
URL = "<the url>"
Set oXMLHTTP = Server.CreateObject("MSXML2.XMLHTTP.6.0")
oXMLHTTP.open "GET", URL, false
oXMLHTTP.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
oXMLHTTP.send
IF oXMLHTTP.Status = 200 THEN
Response.Write oXMLHTTP.ResponseText & "<BR>"
ELSE
Response.Write "Error"
END IF
If I run this exact routine on the classic ASP IIS on my Win XP machine it says invalid class string on the 'Set oXMLHTTP = Server.CreateObject("MSXML2.XMLHTTP.6.0")' line. If I change it from '6' to '5' it can see the object but then it doesn't work again.
I'm taking it that this all means that below v6 does not work with these https sites (TLS issue??) so I need to be using v6, but is this available for Win XP??
Thanks