question

Upvotes
Accepted
1 0 1 1

how to make scheduled extraction

Hi. I have a instrument list, report template, and recurring schedule setup through GUI. All I want to do is use the API to extract the file. How can I find the file to extract, and extract it at certain time during the day once the file is available?

dss-rest-apitick-history-rest-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
32.2k 40 11 19

Hello @nraval,

I would try to verify that there is a completed extraction(s) specifically, for this schedule, run "Get Completed By Schedule ID" to see all the completed extractions that were scheduled, :

{
                {protocol}}{
                {host}}{
                {api}}Extractions/ReportExtractionGetCompleted 

Do you see schedule IDs of completed schedules? Do you see scheduleID of the schedule you require? For example, I see:

{
    "@odata.context": "https://hosted.datascopeapi.reuters.com/RestApi/v1/$metadata#ReportExtractions",
    "value": [
        {
            "ReportExtractionId": "2000000209996076",
            "ScheduleId": "MYSCHEDULEID",
            "Status": "Completed",
            ...
        },
        {
            "ReportExtractionId": "2000000210323640",
            "ScheduleId": "MYSCHEDULEID2",
            "Status": "Completed",
            ...

Try the call with these schedule Ids:

{
                {protocol}}{
                {host}}{
                {api}}Extractions/Schedules('{
                {scheduleId}}')/LastExtractio 

Should see the status in the format:

{
    "@odata.context": "https://hosted.datascopeapi.reuters.com/RestApi/v1/$metadata#ReportExtractions/$entity",
    "ReportExtractionId": "2000000209996076",
    "ScheduleId": "MYSCHEDULEID",
    "Status": "Completed",
    "DetailedStatus": "Done",
    "ExtractionDateUtc": "2021-01-18T16:00:00.000Z",
    "ScheduleName": "myNonImmediateSchedule",
    "IsTriggered": false,
    "ExtractionStartUtc": "2021-01-18T16:00:03.176Z",
    "ExtractionEndUtc": "2021-01-18T16:00:17.656Z"
}

One reason I can think of is you would see the empty result if there is no completed extractions per this schedule

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
32.2k 40 11 19

Hello @nraval,

For working with GUI Control generated extractions, I would like to suggest reviewing REST API Tutorial 12: GUI control calls.

It gives all the fundamentals of working with GUI controls and details how to:

  • Check the status of a scheduled extraction (to know if it is available and getting ExtractionId for the next step)
  • Retrieve the extraction report (by ExtractionId)

The tutorial retrieves by LastExtraction, which is the most common use case.

Your use case may require you to do more, if this is not the last extraction on the schedule, you may need to use ReportExtractionGetCompletedByScheduleId request, to examine the completed extractions for the schedule and determine the ones you wish to retrieve the results for using the same approach.

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.

In the method GetCompletedByScheduleId, how do I get the id? I have an instrument list, report template, and schedule that are not going to change. All I want to do is download the extracted file? in all the sample code, you have to create an instrument list, report template and schedule.

Hello @nraval,

If you do not know the scheduleId of the schedule you are looking for, via API you can run

GET /Extractions/Schedules 

REST API Reference

to obtain all existent schedule Ids and determine the id of the one you are looking to extract.

The tutorial shows how to recreate instrument list, report template and schedule in code, you do not need all this, as you already have those. So likely, you just need steps

"Check Status"

and, once completed, "Retrieve Extraction Report".

Makes sense?


Hello @nraval,

Actually, if you know the name of your schedule (from GUI -> Schedules) a better approach may be

{
                    {protocol}}{
                    {host}}{
                    {api}}Extractions/ScheduleGetByName(ScheduleName='myImmediateSchedule') 

This will return the schedule Id for the submitted schedule name, for example:

{
    "@odata.context": "https://hosted.datascopeapi.reuters.com/RestApi/v1/$metadata#Schedules/$entity",
    "ScheduleId": "0x060987291f2b3036",
    "Name": "myImmediateSchedule",
...

ok great. Let me give that a try! Thanks!

Upvotes
1 0 1 1

I'm able to get the schedule. But now I get this error (attached file) when I run ExtractNow method
Error.txt


error.txt (5.4 KiB)
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
32.2k 40 11 19

Hello @nraval,

GET URL does not not look right, looks off, and that is consistent with "Unmapped Request", this error usually comes up when URL can not be found.

Let us together verify each step we have discussed:

1. You run ScheduleGetByName and obtained ScheduleId for your shcedule

2. You check schedule status, as in tutorial

https://hosted.datascopeapi.reuters.com/RestApi/v1/Extractions/Schedules('0x05a2b98d233b3036')/LastExtraction

and

  1. Status is ok = 200 (otherwise it is not ready to extract yet, repeat periodically)
  2. Once status=200, from the result, you obtain ExtractedFileID such as
{

  "@odata.context": "https://hosted.datascopeapi.reuters.com/RestApi/v1/$metadata#ExtractedFiles
  "value":
   
      "ExtractedFileId": "VjF8MHgwNWEyYjk5ODRiNmIyZjk2fA
      "ReportExtractionId": "2000000000197524
      "ScheduleId": "0x05a2b98d233b3036",

3. You pass ExtractedFileId into extract the result as per tutorial:

https://hosted.datascopeapi.reuters.com/RestApi/v1/Extractions/ExtractedFiles('VjF8MHgwNWEyYjk5ODRiNmIyZjk2fA')/$value 
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
1 0 1 1

Yes. But the lastextraction property is null even though I see an extracted file associated with 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.

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.