question

Upvotes
Accepted
4 1 2 2

How to get ExtractedFileId for Scheduled Completed Extractions.

How do we get the ExtractedFileId values?

I am trying this code, but it does not seem to return any value that I can use to download?

var ExtractionsContext = newExtractionsContext(newUri("https://hosted.datascopeapi.reuters.com/RestApi/v1/"), "USERNAME", “PASSWORD");

var completedExtractions = ExtractionsContext.ReportExtractionOperations.GetCompletedByDateRange(

DateTime.UtcNow.Date.AddDays(-5), DateTime.UtcNow.AddMinutes(5));

tick-history-rest-apirest-api
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
11.3k 25 9 14

@pkosakowski

The download links you provided is for Web GUI only. To programmatically download the extracted file via .Net SDK, you need to call ExtractedFileOperations.GetReadStream() on the extracted file object retrieved by the code I provided in the previous answer. The extracted file normally is downloaded as data stream, so application needs to write the stream to file.

Below is the sample code modified to download an extracted data file of the first completed Report Extraction in the list returned from GetCompletedDateRange.

var completedExtractions = ExtractionsContext.ReportExtractionOperations.GetCompletedByDateRange(

    DateTime.UtcNow.Date.AddDays(-5), DateTime.UtcNow.AddMinutes(5));

var extraction = completedExtractions.FirstOrDefault(e => e.Status == ThomsonReuters.Dss.Api.Extractions.ReportExtractions.ReportExtractionStatus.Completed);
if (extraction != null)
{
    System.Console.WriteLine("Report Extraction Id: {0}", extraction.ReportExtractionId);
    ExtractionsContext.LoadProperty(extraction, "Files");

    //Find the extract file.  Other ExtractedFileTypes are: Note, RicMaintenanceNote, Full, Partial, Other
    var extractFile = extraction.Files.FirstOrDefault(f => f.FileType == ThomsonReuters.Dss.Api.Extractions.ReportExtractions.ExtractedFileType.Full);
    if (extractFile != null)
    {
        //Output the contents of the extracted file
        var streamResponse = ExtractionsContext.ExtractedFileOperations.GetReadStream(extractFile);
        string path = "./" + extractFile.ExtractedFileName;
        

        //Disable automatic decompression
        ExtractionsContext.Options.AutomaticDecompression = false;

        //Save stream to file
        using (Stream s = File.Create(path))
        {
            streamResponse.Stream.CopyTo(s);
        }
    }
}

Please note that the ReadStream will automatically decode data if the extracted file is in gzip format. You can add "ExtractionsContext.Options.AutomaticDecompression = false" to directly write the file without decoding.

For more detail, please see the "Retrieving the extracted files" section in this tutorial and the Streaming section in DSS Key Mechanism.

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.

This code snippet will allow me to download the files as needed. Much appreciated. Thank you!

Request add this as a sample in the DSS Tutorial/ or create a sample in Postman collection

@vinaya.shetty,

REST Tutorial 12 shows the entire workflow around a scheduled extraction, including checking its status and retrieving the files. All the related calls are already available in the existing Postman collection, under the Downloads tab.

Upvotes
11.3k 25 9 14

@pkosakowski

The GetCompletedByDateRange() will return the Collection of ReportExtraction. Each report extraction contains ReportExtractionId. You can access the ExtractedFileId via the "Files" property.

Below is the sample code.

var completedExtractions = ExtractionsContext.ReportExtractionOperations.GetCompletedByDateRange(

    DateTime.UtcNow.Date.AddDays(-5), DateTime.UtcNow.AddMinutes(5));

foreach (var extraction in completedExtractions)
{
    System.Console.WriteLine("Report Extraction Id: {0}", extraction.ReportExtractionId);
    ExtractionsContext.LoadProperty(extraction, "Files");
    foreach (var file in extraction.Files)
    {
        System.Console.WriteLine("Extracted File Name: {0}", file.ExtractedFileName);
        System.Console.WriteLine("Extracted File Id: {0}", file.ExtractedFileId);
    }
}
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
4 1 2 2

Thank you for this reply. It is much appreciated. I think that I must not be asking for the correct field. Your reply gave me the ExtractedFIleID, but that must not be the field we are looking for. We are looking for a way to download our completed extractions.

All of our “COMPLETED EXTRACTIONS” on https://hosted.datascope.reuters.com/datascope/extractions/summary/

Have a download link that uses “ExtractedFile:<%Some FILE ID%>

The download links under Completed Extractions (the scheduled ones) all seem to have this pattern:

https://hosted.datascope.reuters.com/DataScope/extractions/files/EL_Extn_Download.aspx?id=ExtractedFile:FILE_ID

How do we programmatically get that Extracted file identifier?

Once I have that Identifier I can easily download our completed extractions.

Or is there another way to download the Completed Extractions?

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.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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