262 10 15 17

Tick History Time and Sales data through Microsoft VBA, facing issue in downloading zipped files & mentioning file path for downloads.

The client is able to make it work for ‘smaller’ reports – e.g. a Terms and Conditions report, where the returned data is relatively small but not for a Tick History file, specifically around the downloading of Tick History where the files are zipped.

The client is following TRTHv2 API scheduled Workflow: using the ExtractedFIles(fileid)/$value method.'xxExtractedFileIdx')/$value

where my ExtractedFileID is ‘VjF8MHgwNzI5NjU1MzE1YzZiMGM2fA’ under ExtractionID ‘2000000162175976’.

This corresponds to the following schedule:

I can download the output file manually on the web interface, and I can download the corresponding Notes file via the API, but when I run the API GET against the main output – the zipped file - I get a ‘200-OK’ status but just a couple of odd characters in the response text:

I am using the ‘gzip, deflate’ option in my request:

Function download_full_file(FileDownloadURL As String, TRTHToken As String, FileExtractionID As String, FileDownloadStatus As String) As String


Dim FileDownloadURLwithID As String

Dim cutresponse As String

FileDownloadURLwithID = Replace(FileDownloadURL, "xxExtractedFileIdx", FileExtractionID)

objHTTP.Open "GET", FileDownloadURLwithID, False

objHTTP.setRequestHeader "Authorization", "Token " & TRTHToken

objHTTP.setRequestHeader "X-Direct-Download", "true"

objHTTP.setRequestHeader "Accept-Encoding", "gzip, deflate"

objHTTP.setRequestHeader "Accept-Charset", "UTF-8"

objHTTP.setRequestHeader "Prefer", "respond-async"


'InputBox "API Response - copy from below", "API Response", objHTTP.responseText

FileDownloadStatus = objHTTP.Status & " - " & objHTTP.statusText

download_full_file = objHTTP.responseText

End Function

Should I be expecting the files to be returned in the response text, or are they being physically downloaded somewhere for me to use?

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

11.3k 25 9 14

Hi @Beera.Rajesh,

The data extracted from TimeAndSales report template is in gzip format, so responseText contains binary gzip data. The client can write the response to a .gz file, and then decompress data from the .gz file outside of the application.

Below is the sample of code writing response to a .gz file.

        filePath = "C:\\temp\\response.gz"
        fileBytes = objHTTP.responseBody
        Open filePath For Binary As #1
        Put #1, , fileBytes
        Close #1
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.