Not great at object code work, but with some help getting closer. Trying to copy down a zip file from a web link and unzip it. I'm getting a COM oject\Memory error on this line: varByteArray = WinHttpReq.ResponseBody. Any idea why that is happening and what the fix would be?
strFile = "%localpath%"
; Instantiate a WinHttpRequest object.
WinHttpReq = ObjectCreate("WinHttp.WinHttpRequest.5.1")
; Initialize an HTTP request.
WinHttpReq.Open("GET", "%targetfile%", @FALSE)
; Send the HTTP request.
WinHttpReq.Send()
; Display the response text.
varByteArray = WinHttpReq.ResponseBody
buf = BinaryAllocArray(varByteArray)
data = BinaryWrite(buf, strFile)
BinaryFree(buf); Clean up
WinHttpReq = 0
timedelay(1)
zUnZipFiles("u o d", "%localpath%", "*.*", "", "%unziploc%")
timedelay(1)
I tried using this code instead, but it still chokes with a COM error on WinHttpReq.ResponseBody
num="0"
strFile = "%localpath%"
; Instantiate a WinHttpRequest object.
WinHttpReq = ObjectCreate("Microsoft.XMLHTTP")
; Initialize an HTTP request.
WinHttpReq.Open("GET", "%targetfile%", @FALSE)
; Send the HTTP request.
WinHttpReq.Send()
num = WinHttpReq.Status
If num == "200" then
oStream = ObjectCreate("ADODB.Stream")
oStream.Open
oStream.Type = 1
oStream.Write WinHttpReq.ResponseBody
oStream.SaveToFile(strFile)
oStream.Close
Endif
timedelay(1)
zUnZipFiles("u o d", "%localpath%", "*.*", "", "%unziploc%")
timedelay(1)
Your problem has more than one possible cause. It could be that you need to set specific request header information, your file URL is incorrect, or you are attempting to download a massive (gigabytes) file. Don't know which if any of these it might be. What exactly is the text of the error including what you see by pressing the "More Error Info" button?