#Step 4: poll the status of the request using received location URL, and get the jobId and extrac...

...tion notes
###Step 3: send an on demand extraction request using the received token
requestUrl='https://selectapi.datascope.refinitiv.com/RestApi/v1/Extractions/ExtractRaw'
requestHeaders={
'Prefer':'respond-async',
'Content-Type':'application/json',
'Authorization': 'token ' + token
}
requestBody={
"ExtractionRequest": {
"@odata.type": "#DataScope.Select.Api.Extractions.ExtractionRequests.TickHistoryTimeAndSalesExtractionRequest",
"ContentFieldNames": [
"Trade - Price",
"Trade - Volume",
"Trade - Exchange Time"
],
'IdentifierList': {
'@odata.type': '#DataScope.Select.Api.Extractions.ExtractionRequests.InstrumentIdentifierList',
'InstrumentIdentifiers': instrumentList,
},
'Condition': {
"MessageTimeStampIn": "GmtUtc",
"ApplyCorrectionsAndCancellations": "false",
"ReportDateRangeType": "Range",
"QueryStartDate": "2016-09-29T00:00:00.000Z",
"QueryEndDate": "2016-09-29T12:00:00.000Z",
"DisplaySourceRIC": "true"
}
}
}
print('sending the extraction request for the list of option RICs')
r3 = requests.post(requestUrl, json=requestBody, headers=requestHeaders)
#Display the response status, and the location url to use to get the status of the extraction request
#Initial response status after approximately 30 seconds wait will be 202
print ('response status from the extraction request = ' + str(r3.status_code))
#If there is a client side or server side error, display the error information and exit
if r3.status_code >= 400 :
print(r3.text.encode('ascii', 'ignore'))
sys.exit()
#Step 4: poll the status of the request using received location URL, and get the jobId and extraction notes
requestUrl = r3.headers['location']
requestHeaders={
'Prefer': 'respond-async',
'Content-Type': 'application/json',
'Authorization': 'token ' + token
}
r4 = requests.get(requestUrl, headers=requestHeaders)
#The extraction may take a long time for large content sets
#While the extraction is being processed on the server the request status we receive is 202
#We're polling the service for the status every 30 seconds until the status is 200
while r4.status_code == 202 :
r4 = requests.get(requestUrl, headers=requestHeaders)
print (str(dt.datetime.now()) + ' Server is still processing the extraction. Checking the status again in 30 seconds')
time.sleep(30)
---run the code and then the error code as below, please help.
sending the extraction request for the list of option RICs
response status from the extraction request = 200
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
<ipython-input-36-ed1cf426d309> in <module>
46 #Step 4: poll the status of the request using received location URL, and get the jobId and extraction notes
47
---> 48 requestUrl = r3.headers['location']
49
50 requestHeaders={
C:\ProgramData\Anaconda3\lib\site-packages\requests\structures.py in __getitem__(self, key)
50
51 def __getitem__(self, key):
---> 52 return self._store[key.lower()][1]
53
54 def __delitem__(self, key):
KeyError: 'location'
Best Answer
-
Thank you for reaching out to us.
If the status code is 200, there is no need to poll for the status of the request.
Please check the sample code in the LSEG Tick History Python Code Samples.
0
Categories
- All Categories
- 3 Polls
- 6 AHS
- 36 Alpha
- 166 App Studio
- 6 Block Chain
- 4 Bot Platform
- 18 Connected Risk APIs
- 47 Data Fusion
- 34 Data Model Discovery
- 686 Datastream
- 1.4K DSS
- 620 Eikon COM
- 5.2K Eikon Data APIs
- 10 Electronic Trading
- Generic FIX
- 7 Local Bank Node API
- 3 Trading API
- 2.9K Elektron
- 1.4K EMA
- 254 ETA
- 557 WebSocket API
- 38 FX Venues
- 14 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 23 Messenger Bot
- 3 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 60 Open Calais
- 276 Open PermID
- 44 Entity Search
- 2 Org ID
- 1 PAM
- PAM - Logging
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 22 RDMS
- 1.9K Refinitiv Data Platform
- 662 Refinitiv Data Platform Libraries
- 4 LSEG Due Diligence
- LSEG Due Diligence Portal API
- 4 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.2K Screening
- 18 Qual-ID API
- 13 Screening Deployed
- 23 Screening Online
- 12 World-Check Customer Risk Screener
- 1K World-Check One
- 46 World-Check One Zero Footprint
- 45 Side by Side Integration API
- 2 Test Space
- 3 Thomson One Smart
- 10 TR Knowledge Graph
- 151 Transactions
- 143 REDI API
- 1.8K TREP APIs
- 4 CAT
- 27 DACS Station
- 121 Open DACS
- 1.1K RFA
- 104 UPA
- 193 TREP Infrastructure
- 229 TRKD
- 917 TRTH
- 5 Velocity Analytics
- 9 Wealth Management Web Services
- 90 Workspace SDK
- 11 Element Framework
- 5 Grid
- 18 World-Check Data File
- 1 Yield Book Analytics
- 46 中文论坛