#Step 4: poll the status of the request using received location URL, and get the jobId and extractio
###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
- 6 AHS
- 37 Alpha
- 161 App Studio
- 4 Block Chain
- 4 Bot Platform
- 16 Connected Risk APIs
- 47 Data Fusion
- 30 Data Model Discovery
- 608 Datastream
- 1.3K DSS
- 577 Eikon COM
- 4.9K Eikon Data APIs
- 7 Electronic Trading
- Generic FIX
- 7 Local Bank Node API
- Trading API
- 2.7K Elektron
- 1.3K EMA
- 236 ETA
- 519 WebSocket API
- 33 FX Venues
- 10 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 20 Messenger Bot
- 2 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 59 Open Calais
- 264 Open PermID
- 39 Entity Search
- 2 Org ID
- PAM
- PAM - Logging
- 8.4K Private Comments
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 20 RDMS
- 1.4K Refinitiv Data Platform
- 367 Refinitiv Data Platform Libraries
- 3 Refinitiv Due Diligence
- LSEG Due Diligence Portal API
- 3 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.1K Screening
- 18 Qual-ID API
- 13 Screening Deployed
- 23 Screening Online
- 10 World-Check Customer Risk Screener
- 990 World-Check One
- 44 World-Check One Zero Footprint
- 45 Side by Side Integration API
- Test Space
- 3 Thomson One Smart
- 1.2K TR Internal
- Global Hackathon 2015
- 2 Specialists Who Code
- 10 TR Knowledge Graph
- 150 Transactions
- 142 REDI API
- 1.7K TREP APIs
- 4 CAT
- 21 DACS Station
- 117 Open DACS
- 1.1K RFA
- 103 UPA
- 172 TREP Infrastructure
- 224 TRKD
- 886 TRTH
- 5 Velocity Analytics
- 5 Wealth Management Web Services
- 59 Workspace SDK
- 9 Element Framework
- 5 Grid
- 13 World-Check Data File
- Yield Book Analytics
- 46 中文论坛