For a deeper look into our DataScope Select REST API, look into:

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials

question

Upvotes
Accepted
5 4 3 5

Error 202 with TickHistoryTimeAndSalesExtractionRequest

Hi,

I don't understand why I get a 202 error with the following code:


body = json.dumps({
  "ExtractionRequest": {
    "@odata.type": "#ThomsonReuters.Dss.Api.Extractions.ExtractionRequests.TickHistoryTimeAndSalesExtractionRequest",
    "ContentFieldNames": list_trade_fields,
    "IdentifierList": {
      "@odata.type": "#ThomsonReuters.Dss.Api.Extractions.ExtractionRequests.InstrumentIdentifierList",
      "InstrumentIdentifiers": [
        { "Identifier": "SOLB.TG", "IdentifierType": "Ric" }
      ],
      "ValidationOptions": {
        "AllowHistoricalInstruments": True,
        "AllowInactiveInstruments": True,
        "AllowOpenAccessInstruments": False
      },
      "UseUserPreferencesForValidationOptions": False
    },
    "Condition": {
        "ReportDateRangeType" : "Range",
        "QueryStartDate": "2019-08-01T00:00:00.000Z",
        "QueryEndDate": "2019-08-01T10:00:00.000Z"
        }
  }
})

url_post = "https://hosted.datascopeapi.reuters.com/RestApi/v1/Extractions/ExtractRaw"
header_post = {"Prefer": "respond-async, wait=30",
"Content-Type": "application/json",
"Authorization":myToken}
resp = requests.post(url_post,body, headers=header_post)


thank you for your help,

pythondss-rest-apidatascope-selectdssstatus
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.

@i.lucas

Hi,

Thank you for your participation in the forum.

Is the reply below satisfactory in answering your question?

If yes please click the 'Accept' text next to the most appropriate reply. This will guide all community members who have a similar question.

Otherwise please post again offering further insight into your question.

Thanks,

AHS

1 Answer

· Write an Answer
Upvotes
Accepted
22k 58 14 21

Hello @i.lucas, HTTP 202 is not an error code:

202 Accepted
The request has been accepted for processing, but the processing has not been completed. The request might or might not eventually be acted upon, as it might be disallowed when processing actually takes place.

The server sent 202 because in your request you specified:

header_post = {"Prefer": "respond-async, wait=30",

This means that instead of keeping the client connection open for extremely long time, which can be dropped by network proxies/firewalls etc, the server waits 30 seconds and informs client that data isn't ready yet. After getting this response the client should wait and invoke another request for same URL until server responds with a HTTP200 OK message. Here is a snippet for doing that in python:

# is it a 202 (in progress)
while (resp.status_code == 202):
    print("waiting...");
    # check if the response completed yet
    URL = resp.headers['Location'];
    resp = checkStatus(URL);

print("Data available on server, fetching...");
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.