question

Upvotes
Accepted
262 12 15 19

I am seeing 202 Accepted with header value “status” => “InProgress” and not “200 OK”.

Request

Header:

'prefer' => 'respond-async',
'content-type' => 'application/json; odata=minimalmetadata',
'content-length' => 0,'authorization' => 'Token _cehY******'

Body:

{
  "ExtractionRequest":
  {
    "@odata.type":"#ThomsonReuters.Dss.Api.Extractions.ExtractionRequests.TickHistoryTimeAndSalesExtractionRequest",
    "ContentFieldNames":[
      "Trade - Price",
      "Trade - Volume"
    ],
    "IdentifierList":
    {
      "@odata.type":"#ThomsonReuters.Dss.Api.Extractions.ExtractionRequests.InstrumentIdentifierList",
      "InstrumentIdentifiers":[
        { "Identifier":"VOD.L",
          "IdentifierType":"Ric"
        },
        { "Identifier":"IBM.N",
          "IdentifierType":"Ric"
        }
      ],
      "ValidationOptions":null,
      "UseUserPreferencesForValidationOptions":false
    },
    "Condition":
    {
      "MessageTimeStampIn":"GmtUtc",
      "ApplyCorrectionsAndCancellations":true,
      "ReportDateRangeType":"Range",
      "QueryStartDate":"2017-01-01T09:00:00.000",
      "QueryEndDate":"2017-01-01T10:00:00.000",
      "DisplaySourceRIC":false
    }
  }
}

Response

Code: 202 Accepted

Header:

'x-app-id' => 'Custom.RestApi',
'cache-control' => 'no-cache',
'set-cookie' => 'DSSAPI-COOKIE=R2817038826; path=/',
'date' => 'Thu, 08 Jun 2017 19:19:54 GMT',
'status' => 'InProgress',
'client-ssl-cert-issuer' => '/C=US/O=Symantec Corporation/OU=Symantec Trust Network/CN=Symantec Class 3 Secure Server CA - G4',
'client-ssl-cipher' => 'RC4-SHA',
'client-peer' => '192.165.219.152:443',
'client-date' => 'Thu, 08 Jun 2017 19:19:54 GMT',
'client-ssl-warning' => 'Peer certificate not verified',
'x-request-execution-correlation-id' => '528c84b5-da5f-42ad-9610-77d741818a07',
‘pragma' => 'no-cache',
'server' => 'Microsoft-IIS/7.5',
'client-ssl-socket-class' => 'IO::Socket::SSL',
‘client-response-num' => 1,
'location' => 'https://hosted.datascopeapi.reuters.com/RestApi/v1/Extractions/ExtractRawResult(ExtractionId=\'0x05bfd3812aab3026\')',
'progress' => '',
'content-length' => '0',
'x-app-version' => '11.0.492.64',
'client-ssl-cert-subject' => '/C=US/ST=New York/L=New York/O=Thomson Reuters/CN=hosted.datascopeapi.reuters.com',
'expires' => '-1'

This response just continuously loops. I left it for 2 hours yesterday with no difference.

Strangely, I ran the job about ten mins ago and it actually returned something different:

Code: 200 OK

This seems to be the correct response. I just re-ran now and back to the infinite loop. Any ideas why it does not return something every time?

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
13.7k 26 8 12

@Beera.Rajesh

The behavior you see is normal. After using POST to submit an On Demand request, receiving a 202 Accepted means the request was accepted by the server, and is currently being processed. That is why the status is In Progress.

If you POST the same query again you are submitting a second instance of the query.

So, after using POST to submit a request, you will usually receive a 202 Accepted (I say usually, because if the request is very small it might actually complete and return a 200 if it takes less than 30 seconds, but this is a rare occurence). In the 202 header you also have an item called Location, which is an URL. Save it. The next step is to query that URL with a GET, to check the status of the extraction. The location URL looks like this:

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

The GET to the location URL will either return a 202 Accepted or a 200 OK. If you receive a 202 it means the extraction has not yet completed, you must wait, and then repeat the GET query to the location URL, until you receive a 200 OK. Once you receive a 200 OK, then extract the value of the JobId (it looks like this: 0x05a64ba76a4b3036) from the body of the response.

The final step, to retrieve the data, is a GET to a URL of this form:

https://hosted.datascopeapi.reuters.com/RestApi/v1/Extractions/RawExtractionResults('0x05a64ba76a4b3036')/$value

Note that this URL contains the JobId. The response will contain the data you initially requested.

The entire workflow is described in detail in the REST API Tutorial 3.

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.

Christiaan Meihsl , Thank you for the response. But the client has mentioned he had Ieft it for 2 hours and he doesn't see any difference. So what is the expected time to see the message 202 Accepted changed to 200 Ok (What are the key factors for this time)?

@Beera.Rajesh

The request above is a small request. I just tested it to give you an idea of the execution time:

  • 00:00 POST request
  • 00:30 Receive 202
  • 00:35 GET location URL
  • 00:45 Response contains JibId

=> It took less than 1 minute.

Please double check that the customer is following the correct workflow, as described in my answer above.

Upvotes
32.2k 40 11 20

Hi @Beera.Rajesh ,

As Christiaan has explained above, the approach should be:

1. Initiate the request

2. While the response is 202, keep checking periodically, as illustrated by Postman Tutorials "Check..." and in Java examples code

3. Once it's 200, proceed to retrieve.

Hope this helps

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.