question

Upvotes
Accepted
19 3 5 6

TRTH REST : Download a file with Postman

I use direct HTTP requests / C++

It seems much more difficult to download the results in a file than with the TRTH SOAP version.

Once a request is completed, is there a simple HTTP request which allows to download a file on my own machine ?

I tried this with Postman : https://hosted.datascopeapi.reuters.com/RestApi/v1/Extractions/ExtractedFiles(‘VjF8MHgwNWNjOWMxYWUwZmIyZjk2fA’)/$value

and got 400 Bad request Obviously I am aware I do not provide a filename but as my previous request gave me the result below, I thought a _OnD_0x05cc9c10851b2f86.csv.gz file were going to appear somewhere on my disk... { "@odata.context": " https://hosted.datascopeapi.reuters.com/RestApi/v1/$metadata#ExtractedFiles", "value": [ { "ExtractedFileId": "VjF8MHgwNWNjOWMxYWY1N2IyZjk2fA", "ReportExtractionId": "2000000001260285", "ScheduleId": "0x05cc9c10851b2f86", "FileType": "Note", "ExtractedFileName": "_OnD_0x05cc9c10851b2f86.csv.gz.notes.txt", "LastWriteTimeUtc": "2017-07-18T12:31:45.620Z", "ContentsExists": true, "Size": 1186, "ReceivedDateUtc": "2017-07-18T12:31:45.620Z" }, { "ExtractedFileId": "VjF8MHgwNWNjOWMxYWUwZmIyZjk2fA", "ReportExtractionId": "2000000001260285", "ScheduleId": "0x05cc9c10851b2f86", "FileType": "Full", "ExtractedFileName": " _OnD_0x05cc9c10851b2f86.csv.gz", "LastWriteTimeUtc": "2017-07-18T12:31:44.000Z", "ContentsExists": true, "Size": 2029220 } ] }
tick-history-rest-apiDownloadpostman
icon clock
10 |1500

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

Upvotes
Accepted
13.7k 26 8 12

@Jerome Guiot-Dorel

The error message says the URL is invalid. Looking at it very closely I think I found what is wrong with it. The URL should use the following character around the file ID: '

But your URL uses ‘ and ’, these are 2 different characters. This can happen when pasting in/out of word.

Try this, it should work:

https://hosted.datascopeapi.reuters.com/RestApi/v1/Extractions/ExtractedFiles('VjF8MHgwNWNjOWMxYWUwZmIyZjk2fA')/$value

icon clock
10 |1500

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

Upvotes
13.7k 26 8 12

@Jerome Guiot-Dorel,

I'm guessing you are doing a scheduled extraction, using an instrument list, report template and schedule. Please correct me if my assumption is wrong.

First of all, to retrieve the data, you do not need to provide a filename but an extracted file ID, so you are perfectly correct in making a call to https://hosted.datascopeapi.reuters.com/RestApi/v1/Extractions/ExtractedFiles(‘VjF8MHgwNWNjOWMxYWUwZmIyZjk2fA’)/$value, that is the correct way to retrieve the file contents.

I don't know why you got a 400 Bad request. Did you do a GET or a POST to this URL ? You need to do a GET. If you did use a GET, then could you post the error that was delivered with the 400 Bad Request ? It will help to debug.

Second, Postman will not save the file to disk. It will automatically decompress the contents, and display them on screen (there are limits to the file size Postman can handle, so don't request too much data otherwise it will hang).

We do not have C++ samples, but if you download the Java samples (from the downloads tab) and look at one of the three "DSS2ImmediateSchedule" samples you will easily understand the logic, and how we save the compressed data file to disk. I hope this helps, even if the programming language is not the same.

For more details, the entire workflow of a scheduled extraction is described in REST API Tutorial 12. If you download the Postman collection (from the downloads tab), install it and its associated environment, you can also run all the calls of this tutorial to see how Postman should react.

icon clock
10 |1500

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

Upvotes
19 3 5 6

Yes ! : scheduled / instrument list / template

Before jumping on my C++ compiler, I wanted to go through the whole process.

The details of the error I got was :

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd"> <HTML> <HEAD> <TITLE>Bad Request</TITLE> <META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"> </HEAD> <BODY> <h2>Bad Request - Invalid URL</h2> <hr> <p>HTTP Error 400. The request URL is invalid.</p> </BODY> </HTML>

To be honest, I do not understand at all.

BTW, when I asked for a RawExtractionResults(), it works perfectly and my Postman browser printed the correct flow.

I am going to look at your examples in Java. If you could post an example in C++ for downloading files, I think it will be much appreciated.

Thank you

icon clock
10 |1500

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

Upvotes
19 3 5 6

OK

It works

Thank you very much

icon clock
10 |1500

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

Great, happy to hear that :-)

Click below to post an Idea Post Idea