Question Thembelani Mlalazi · May 18, 2023

How to understand the HTTPRequest Error Object reference required

I am trying to call to a website that renders a xml structure as a response.if I put the url on the browser an xml rendered page is returned but if i call to this using the below code I get an object reference error which I am finding had to understand is there anyone who could help understand this error or point me in the right direction thanks.

Set tSC=$$$OK

  Set httpRequest = ##class(%Net.HttpRequest).%New()Set httpRequest.Server = "msedgewebdriverstorage.blob.core.windows.net"
  Set httpRequest.Port=443
   Set httpRequest.ContentType ="application/octet-stream" 
    ;;"application/xml"
    Set httpRequest.SSLConfiguration="Open"
    Set httpRequest.Https=1
    Do httpRequest.Get("/edgewebdriver"_$C(63)_"comp=list")
    
    
    Do $System.OBJ.Dump(httpRequest.HttpResponse)

please note the SSL is just an empty SSL configuration to be able to use https

Product version: Caché 2018.1
$ZV: Cache for Windows (x86-64) 2018.1.4 (Build 505_1U) Thu May 28 2020 10:01:40 EDT [HealthShare Modules:Core:15.032.9035 + Linkage Engine:15.032.9035]

Comments

Julius Kavay · May 18, 2023

I have no idea, from which error you talk.

ClassMethod MyRequest()
{
	set req = ##class(%Net.HttpRequest).%New()
	set req.Server = "msedgewebdriverstorage.blob.core.windows.net"set req.SSLConfiguration="Open"set req.Https=1do req.Get("/edgewebdriver/?comp=list")
	set rsp=req.HttpResponse
	
	if rsp.StatusCode=200 {
		write"Data Size: ",rsp.Data.Size,!
		write"Dumping the first 256 bytes..."zzdump rsp.Data.Read(256)
		
	} else {
		write"Return Code: ",rsp.StatusCode,!
		write"Resp.Phrase: ",rsp.ReasonPhrase,!
	}
	
	quit rsp
}

The output is just fine... no errors.

do##class(...).MyRequest() --->

Data Size: 1832857
Dumping the first 256 bytes...
0000: EF BB BF 3C 3F 786D6C 2076657273696F 6E         <?xml version
0010: 3D22312E 302220656E 636F 64696E 673D         ="1.0" encoding=
0020: 227574662D38223F 3E 3C 456E 756D6572"utf-8"?><Enumer
0030: 6174696F 6E 526573756C 747320436F 6E         ationResults Con
0040: 7461696E 65724E 616D653D2268747470         tainerName="http
0050: 73 3A 2F 2F 6D 73 65 64 67 65 77 65 62 64 72 69         s://msedgewebdri
0060: 76 65 72 73 74 6F 72 61 67 65 2E 62 6C 6F 62 2E         verstorage.blob.
0070: 63 6F 72 65 2E 77 69 6E 64 6F 77 73 2E 6E 65 74         core.windows.net
0080: 2F 65 64 67 65 77 65 62 64 72 69 76 65 72 2F 22         /edgewebdriver/"0090: 3E 3C 426C 6F 62733E 3C 426C 6F 623E 3C 4E         ><Blobs><Blob><N
00A0: 616D653E 3130302E 302E 313135342E 30         ame>100.0.1154.0
00B0: 2F 656467656472697665725F 61726D36         /edgedriver_arm6
00C0: 342E 7A 69703C 2F 4E 616D653E 3C 55726C         4.zip</Name><Url
00D0: 3E 68747470733A 2F 2F 6D736564676577         >https://msedgew00E0: 656264726976657273746F 726167652E         ebdriverstorage.
00F0: 626C 6F 622E 636F 72652E 77696E 646F 77         blob.core.window

You have to work with the Data property of the response object (which is a 1.8MB  stream)

0
Thembelani Mlalazi · Jun 1, 2023

Having tested this outside a restricted environment I realised my problem was the proxy server as the htttpResponse was not being instantiated, the work around was to use the proxy sever and running everything through the proxy tunnel.

ClassMethod MyReq()
{
set tSC=$$$OK
set req = ##class(%Net.HttpRequest).%New()
set req.Server = "msedgewebdriverstorage.blob.core.windows.net"
set req.ProxyPort=**
set req.ProxyServer="*******"
set req.ProxyHTTPS=1
set req.ProxyTunnel=1
set req.SSLConfiguration="Open"do:tSC req.Get("/edgewebdriver/?comp=list")     Do $System.OBJ.Dump(req.HttpResponse)
quit tSC
}

0