question

Upvotes
Accepted
19 3 7 7

Do we need always three HTTP requests to download a file after the initial request ?

I am working on TRTH REST - API - C++ - On demand extraction

All is working fine :
I sent a request
=> I get an extraction ID (sth like '0x05d8855d69cb3036')
=> I then get a reportID (sth like '2000000001865568')
=> I then get an extractedFileID (sth like 'VjF8MHgwNWQ4ODU2YzU0MmIzMDI2fA')

However, in this third request I notice in the body of the reply a field extractedFileName = '_OnD_0x05d8855d69cb3036.csv.gz'. I was wondering whether it could be possible to download directly the result file with this file name information since it is easy to build this string from the extractionID obtained by the initial request.

I am aware I should anyway wait for a status 'Completed' (status = 200) of the request before trying a download.

Best regards

tick-history-rest-apiDownloadon-demand-extraction
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.

Upvotes
Accepted
53.2k 138 44 63

For On Demand extraction, after getting the ExtractionId and the status is completed (200), the response will contain the JobId which is the same value as ExtractionId.

GET https://hosted.datascopeapi.reuters.com/RestApi/v1/Extractions/ExtractRawResult(ExtractionId='0x05d865a51a7b2f96')

RESPONSE 
STATUS 200 OK
{
    "@odata.context": "https://hosted.datascopeapi.reuters.com/RestApi/v1/$metadata#RawExtractionResults/$entity",
    "JobId": "0x05d865a51a7b2f96",
    "Notes": [
        "Extraction Services Version 11.1.37192 (54656a7aa87e), Built Aug  9 2017 15:35:02\nUser ID: 9008895\nExtraction ID: 2000000001853403\nSchedule: 0x05d865a51a7b2f96 (ID = 0x0000000000000000)\nInput List (1 items):  (ID = 0x05d865a51a7b2f96) Created: 08/24/2017 10:27:50 Last Modified: 08/24/2017 10:27:50\nReport Template (120 fields): _OnD_0x05d865a51a7b2f96 (ID = 0x05d865a52d0b2f96) Created: 08/24/2017 10:27:05 Last Modified: 08/24/2017 10:27:05\nSchedule dispatched via message queue (0x05d865a51a7b2f96), Data source identifier (4955E8FEB448405D94AC1747B054C192)\nSchedule Time: 08/24/2017 10:27:07\nProcessing started at 08/24/2017 10:27:07\nProcessing completed successfully at 08/24/2017 10:27:51\nExtraction finished at 08/24/2017 03:27:51 UTC, with servers: tm04n01\nInstrument <RIC,CARR.PA> expanded to 1 RIC: CARR.PA.\nQuota Message: INFO: Tick History Cash Quota Count Before Extraction: 1910; Instruments Extracted: 0; Tick History Cash Quota Count After Extraction: 1910, 382% of Limit; Tick History Cash Quota Limit: 500\nQuota Message: WARNING: Tick History Cash Quota has been reached or exceeded\nManifest: #RIC,Domain,Start,End,Status,Count\nManifest: CARR.PA,Market Price,2017-07-18T04:16:42.143815611Z,2017-07-18T11:59:49.652317454Z,Active,71068\n"
    ]
}

Then, you can use HTTP GET with /Extractions/RawExtractionResults('0x05d865a51a7b2f96')/$value to get the file.

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.

Upvotes
19 3 7 7

Hello !

/Extractions/RawExtractionResults('0x05d865a51a7b2f96')/$value allows to display the data in a browser (it they are not too big) but does it allow to save a file myFile.csv.gz ?

It is perfect to check data in Postman but to download a file, is it the good way ?

If so, could you please elaborate with an example ?

Regards

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.

Refer to REST API Reference Tree, Extractions/RawExtractionResults({id})/$value returns the native/raw contents of the extraction. The content is in .csv.gz format.

When it is in gz format, most applications typically decompress the retrieved data and then display it as CSV.

You can verify it by using curl to down the file from RawExtractionResults('0x05d983da410b3016')/$value.

curl -k -X GET -H "Authorization: Token <token>" -o outfile.csv.gz https://hosted.datascopeapi.reuters.com/RestApi/v1/Extractions/RawExtractionResults%28%270x05d983da410b3016%27%29/%24value