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

  • Gurpreet
    Gurpreet admin
    Answer ✓

    Hi @leszek.lubecki01,

    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***DDD74

    Here is the description in the RDP documentation:

    image

    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)


Answers