Response(is_success=False, request_message=

I trying below code but getting error. Please see the below error and response error as well. It was working well till yesterday, But now error again.


from datetime import date

import refinitiv.data as rd

startdate=str(date.today()+timedelta(days=-10))

enddate=str((date.today())+timedelta(days=375))

rd.open_session()

url_ = "https://api.refinitiv.com/analytics/functions/v1/common/list-holidays"

body = {"universe": [{"startDate": startdate, "endDate": enddate, "calendarCodes": ["USA","UKG","IRL"]}]}


request_ = rd.delivery.endpoint_request.Definition(method=rd.delivery.endpoint_request.RequestMethod.POST,url=url_,body_parameters=body,)


response = request_.get_data()

holidays = pd.DataFrame(response.data.raw["data"][0]["holidays"])['date'].unique()

print(holidays)

---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
Cell In[20], line 1
----> 1 holidays = pd.DataFrame(response.data.raw["data"][0]["holidays"])['date'].unique()

KeyError: 'data'




In[21]: response

Out[21]:

Response(is_success=False, request_message=<Request('POST', 'http://localhost:9060/api/rdp/analytics/functions/v1/common/list-holidays')>, http_response=<Response [403 Forbidden]>, http_headers=Headers({'access-control-allow-origin': '*', 'x-request-id': '615b825d-92d4-4cd0-976d-63d01de7ed73', 'content-type': 'text/html; charset=utf-8', 'content-length': '666', 'etag': 'W/"29a-NJjwKCOUPKrBNJgkBAgitl03pHc"', 'date': 'Wed, 27 Sep 2023 10:44:22 GMT', 'connection': 'keep-alive'}), http_status={'http_status_code': 403, 'http_reason': 'Forbidden'}, errors=[Error(code=403, message='<html>\n<head>\n<title>Forbidden</title>\n<style type="text/css">\nbody {\n  background-color: #242424;\n  color: #c8c7c7;\n  font-family: Calibri, Helvetica, Arial, sans-serif;\n  font-size: 16px;\n}\n</style>\n</head>\n<!-- Request \nReferer: https://emea1-apps.platform.refinitiv.com/Apps/data-api-proxy-csm/1.3.1/\nUser-Agent: Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.4389.0.124 EikonViewer/89.4389.0.124 Safari/537.36\n-->\n<!-- Response\nServer: LO5P-ERPA08\nDate: Wed, 27 Sep 2023 10:44:22 GMT\nHTTP Code: 403\nHTTP Response: Forbidden\nX-Varnish: 59098369\nBackend: default\n-->\n<body>\n <h1>Forbidden</h1>\n <p>Invalid token</p>\n</body>\n</html>')], closure=None, requests_count=1, _data_factory=<refinitiv.data.delivery._data._response_factory.ResponseFactory object at 0x0000020F2373B370>, _kwargs={'session': <refinitiv.data.session.Definition object at 0x20f26f3a320 {name='workspace'}>, 'method': <RequestMethod.POST: 'POST'>, 'path_parameters': None, 'query_parameters': None, 'header_parameters': None, 'body_parameters': {'universe': [{'startDate': '2023-09-17', 'endDate': '2024-10-06', 'calendarCodes': ['USA', 'UKG', 'IRL']}]}}, _raw={})

Best Answer

  • Jirapongse
    Jirapongse admin
    Answer ✓

    @roman.lutz

    Thank you for reaching out to us.

    I can run the code properly.

    1695872936549.png

    It could be the problem in the backend because the error is:

    1695873068483.png

    You can enable logging in the RD library to verify what the problem is.

    {
      ...
      "logs": {
        "level": "debug",
        "transports": {
          "console": {
            "enabled": false
          },
          "file": {
            "enabled": true,
            "name": "refinitiv-data-lib.log"
          }
        }
      },
    ...

    Please refer to the examples on GitHub regarding how to use the configuration file.

    However, if it is better to contact the helpdesk support team via MyRefinitiv to verify the problem on the backend.