News retrieval using rdp.get_news_story
Hi Team,
I am trying to pull in news stories using rdp.get_news_story, but no format seems to be working
I am using a dedicated RDP account and I can pull in headlines just fine ex. using
rdp.get_news_headlines(query="R:VOD.L AND LEN", date_from="2021-03-06T09:00:00", \
date_to="2021-03-08T18:00:00", count=10, sort_order='newToOld')
but the subsequent story retrieval isn't working ex. for story ID urn:newsml:reuters.com:20210308:nBw12DM8da:1
I would assume it would behave the same way as eikon DAPI where I just need to supply the ID/PNAC string but the below don't work
rdp.get_news_story(story_id='urn:newsml:reuters.com:20210308:nBw12DM8da:1')
rdp.get_news_story(story_id='nBw12DM8da')
I also tried parsing the url into the same format indicated in the context menu for the function, but still no luck
import urllib
test = urllib.parse.quote('urn:newsml:reuters.com:20210308:nBw12DM8da:1', \
encoding='utf-8', errors='replace')
rdp.get_news_story(story_id=test)
Any hints how to access the story using that ID?
Best Answer
-
I think this is a shortcoming in the RDP Python library. The library is sending in an accept header with */*, where as the documentation clearly mentions that only text/html or application/json is accepted. The server response is different based on what the application sends in accept header.
RDP library:
GET https://api.refinitiv.com/data/news/v1/stories/urn:newsml:reuters.com:20210308:nBw12DM8da:1 HTTP/1.1
host: api.refinitiv.com
user-agent: python-httpx/0.14.3
accept: */*
accept-encoding: gzip, deflate
connection: keep-alive
authorization: Bearer ***
x-tr-applicationid: D6D7***DDD74Here is the description in the RDP documentation:
I will raise this issue with the product team. Meanwhile, if you like, you can use requests module to make your own API call to news story:
import requests
headers = {
'Accept': 'application/json',
'Authorization': 'Bearer **YOUR ACCESS TOKEN**'
}
response = requests.request("GET", "https://api.refinitiv.com/data/news/v1/stories/urn:newsml:reuters.com:20210308:nBw12DM8da:1", headers=headers, data={})
print(response.text)0
Answers
-
The proper way to retrieve a story is how you performed above with the following line:
rdp.get_news_story(story_id='urn:newsml:reuters.com:20210308:nBw12DM8da:1')
Can you retrieve the status from this call? Do this:
rdp.get_last_status()
0 -
Hey @nick.zincone
I get this:
{'http_status_code': 400, 'http_reason': 'Bad Request', 'error': {'id': 'acac01d2-4b36-4299-bb83-364a859e59be', 'code': '400', 'message': 'Validation error', 'status': 'Bad Request', 'errors': [{'key': 'accept', 'reason': 'validation failure list:\naccept in header should be one of [application/json text/html]'}]}}
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
- 687 Datastream
- 1.4K DSS
- 622 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
- 671 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
- 918 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
- 48 中文论坛