get_data() AttributeError: 'dict' object has no attribute 'url' using rdp

dewi
dewi Newcomer

Answers

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    @dewi

    Thank you for reaching out to us.

    The error is similar to the error on this discussion.

    It may relate to the version of httpx installed on a Python environment. Therefore, please check the version of httpx.

    C:\Users\U8009686>pip show httpx
    WARNING: Ignoring invalid distribution ~lotly (C:\Python312\Lib\site-packages)
    Name: httpx
    Version: 0.26.0
    Summary: The next generation HTTP client.
    Home-page: https://github.com/encode/httpx
    Author:
    Author-email: Tom Christie <tom@tomchristie.com>
    License:
    Location: C:\Python312\Lib\site-packages
    Requires: anyio, certifi, httpcore, idna, sniffio
    Required-by: eikon, jupyterlab, lseg-data, refinitiv-data, refinitiv-dataplatform
  • dewi
    dewi Newcomer
    image.png

    should we set up the proxy or what's I don't get any answer from the discussion that you attached

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    @dewi

    The client didn't share the resolution but I understand it should relate the proxy settings or dependency libraries.

    You can check the version of httpx when the problem occurred on this page.

    image.png

    When you got the error, please run the following code on the same page.

    import httpx
    print(httpx.__version__)
    
  • dewi
    dewi Newcomer

    The version is 0.26.0

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    @dewi

    Can you share the full call stack?

    I need to make sure that it is the same issue.

  • dewi
    dewi Newcomer


    AttributeError: 'dict' object has no attribute 'url'File <command-4644964099624786>, line 4 1 response = rd.content.pricing.Definition( 2 ['EUR=', 'GBP=', 'JPY=', 'CAD='], 3 fields=['BID', 'ASK']----> 4 ).get_data()File /local_disk0/.ephemeral_nfs/envs/pythonEnv-7585eb21-5d87-405a-b12b-d8c07078895b/lib/python3.12/site-packages/refinitiv/data/content/_content_provider_layer.py:58, in ContentUsageLoggerMixin.get_data(self, session, on_response) 51 # Library usage logging 52 get_usage_logger().log_func( 53 name=f"
    {ModuleName.CONTENT}.{self._USAGE_CLS_NAME}.get_data", 54 func_path=f"{self.__class__.__module__}.{self.__class__.__qualname__}.get_data", 55 kwargs={**self._kwargs}, 56 desc={FilterType.SYNC, FilterType.LAYER_CONTENT}, 57 )---> 58 return super().get_data(session, on_response)File /local_disk0/.ephemeral_nfs/envs/pythonEnv-7585eb21-5d87-405a-b12b-d8c07078895b/lib/python3.12/site-packages/refinitiv/data/delivery/_data/_data_provider_layer.py:149, in DataProviderLayer.get_data(self, session, on_response) 133 """ 134 Sends a request to the client file store to retrieve the previously defined data. 135 (...) 146 147 """ 148 session = get_valid_session(session)--> 149 response = get_data(self._data_type, self._provider, session, **self._kwargs) 150 if on_response is not None: 151 warnings.warn( 152 "Avoid using on_response for get_data method, it will be removed in future library version v2.0.", 153 category=FutureWarning, 154 )File /local_disk0/.ephemeral_nfs/envs/pythonEnv-7585eb21-5d87-405a-b12b-d8c07078895b/lib/python3.12/site-packages/refinitiv/data/delivery/_data/_data_provider_layer.py:51, in get_data(data_type, provider, session, **kwargs) 44 # Library usage logging 45 get_usage_logger().log_func( 46 name=f"{ModuleName.DELIVERY}.{DataProviderLayer._USAGE_CLS_NAME}.get_data", 47 func_path=f"{DataProviderLayer.__module__}.{DataProviderLayer.__qualname__}.get_data", 48 kwargs={"url": url, "auto_retry": auto_retry, **kwargs}, 49 desc={FilterType.SYNC, FilterType.LAYER_DELIVERY}, 50 )---> 51 response = provider.get_data(session, url, auto_retry=auto_retry, **kwargs) 52 return responseFile /local_disk0/.ephemeral_nfs/envs/pythonEnv-7585eb21-5d87-405a-b12b-d8c07078895b/lib/python3.12/site-packages/refinitiv/data/delivery/_data/_data_provider.py:80, in DataProvider.get_data(self, session, *args, **kwargs) 78 raise_if_closed(session) 79 request = self.request.create(session, *args, **kwargs)---> 80 raw_response = self.connection.send(request, session, *args, **kwargs) 81 return self._process_response(raw_response, request, session, *args, **kwargs)File /local_disk0/.ephemeral_nfs/envs/pythonEnv-7585eb21-5d87-405a-b12b-d8c07078895b/lib/python3.12/site-packages/refinitiv/data/delivery/_data/_connection.py:14, in HttpSessionConnection.send(self, request, session, auto_retry, *args, **kwargs) 11 def send(self, request: Request, session: "Session", *args, auto_retry=False, **kwargs) -> "httpx.Response": 12 request.auto_retry = auto_retry---> 14 return session.http_request(request)File /local_disk0/.ephemeral_nfs/envs/pythonEnv-7585eb21-5d87-405a-b12b-d8c07078895b/lib/python3.12/site-packages/refinitiv/data/_core/session/_platform_session.py:255, in PlatformSession.http_request(self, request) 254 def http_request(self, request: "Request") -> "httpx.Response":--> 255 return self._connection.http_request(request)File /local_disk0/.ephemeral_nfs/envs/pythonEnv-7585eb21-5d87-405a-b12b-d8c07078895b/lib/python3.12/site-packages/refinitiv/data/_core/session/connection.py:258, in RefinitivDataConnection.http_request(self, request) 257 def http_request(self, request: "Request") -> httpx.Response:--> 258 return self._session._http_service.request(request)File /local_disk0/.ephemeral_nfs/envs/pythonEnv-7585eb21-5d87-405a-b12b-d8c07078895b/lib/python3.12/site-packages/refinitiv/data/_core/session/http_service.py:333, in HTTPService.request(self, request) 331 def request(self, request: "Request") -> httpx.Response: 332 if self._client.is_closed():--> 333 self._client.open() 335 try: 336 response = self._client.send(request)File /local_disk0/.ephemeral_nfs/envs/pythonEnv-7585eb21-5d87-405a-b12b-d8c07078895b/lib/python3.12/site-packages/refinitiv/data/_core/session/http_service.py:179, in HTTPClient.open(self) 175 proxies = self._session._proxies.get_proxy_for_httpx() 177 # httpx has its default Accept header and 178 # server wants application/json or nothing--> 179 self._client = get_httpx_client( 180 headers={"Accept": APPLICATION_JSON}, 181 limits=limits, 182 proxies=proxies, 183 ) 185 key = configure.keys.http_auto_retry_config 186 auto_retry_config = config.get(key, None)File /local_disk0/.ephemeral_nfs/envs/pythonEnv-7585eb21-5d87-405a-b12b-d8c07078895b/lib/python3.12/site-packages/refinitiv/data/_core/session/http_service.py:152, in get_httpx_client(proxies, **kwargs) 150 def get_httpx_client(proxies, **kwargs): 151 if httpx.__version__ >= "0.26.0":--> 152 client = httpx.Client(proxy=proxies, **kwargs) 153 else: 154 client = httpx.Client(proxies=proxies, **kwargs)File /databricks/python/lib/python3.12/site-packages/httpx/_client.py:700, in Client.__init__(self, auth, params, headers, cookies, verify, cert, trust_env, http1, http2, proxy, mounts, timeout, follow_redirects, limits, max_redirects, event_hooks, base_url, transport, default_encoding) 686 proxy_map = self._get_proxy_map(proxy, allow_env_proxies) 688 self._transport = self._init_transport( 689 verify=verify, 690 cert=cert, (...) 695 transport=transport, 696 ) 697 self._mounts: dict[URLPattern, BaseTransport | None] = { 698 URLPattern(key): None 699 if proxy is None--> 700 else self._init_proxy_transport( 701 proxy, 702 verify=verify, 703 cert=cert, 704 trust_env=trust_env, 705 http1=http1, 706 http2=http2, 707 limits=limits, 708 ) 709 for key, proxy in proxy_map.items() 710 } 711 if mounts is not None: 712 self._mounts.update( 713 {URLPattern(key): transport for key, transport in mounts.items()} 714 )File /databricks/python/lib/python3.12/site-packages/httpx/_client.py:750, in Client._init_proxy_transport(self, proxy, verify, cert, trust_env, http1, http2, limits) 740 def _init_proxy_transport( 741 self, 742 proxy: Proxy, (...) 748 limits: Limits = DEFAULT_LIMITS, 749 ) -> BaseTransport:--> 750 return HTTPTransport( 751 verify=verify, 752 cert=cert, 753 trust_env=trust_env, 754 http1=http1, 755 http2=http2, 756 limits=limits, 757 proxy=proxy, 758 )File /databricks/python/lib/python3.12/site-packages/httpx/_transports/default.py:168, in HTTPTransport.__init__(self, verify, cert, trust_env, http1, http2, limits, proxy, uds, local_address, retries, socket_options) 155 if proxy is None: 156 self._pool = httpcore.ConnectionPool( 157 ssl_context=ssl_context, 158 max_connections=limits.max_connections, (...) 166 socket_options=socket_options, 167 )--> 168 elif proxy.url.scheme in ("http", "https"): 169 self._pool = httpcore.HTTPProxy( 170 proxy_url=httpcore.URL( 171 scheme=proxy.url.raw_scheme, (...) 185 socket_options=socket_options, 186 ) 187 elif proxy.url.scheme in ("socks5", "socks5h"):Diagnose errorDebugAssistant Quick Fix: OFF Code Text Assistant

  • Hello @dewi

    Can you try with the latest https://developers.lseg.com/en/api-catalog/lseg-data-platform/lseg-data-library-for-python ( https://pypi.org/project/lseg-data/ ) which is the Data Library version 2?

    The library interfaces are mostly the same as Refinitiv Data Library (Data Library version 1) except the get_data() method requires the fields parameter.

    I strongly suggest you try with a new Python virtual environment (venv or conda).

  • dewi
    dewi Newcomer

    I already use the lseg data but got the same issue

    image.png
  • Jirapongse
    Jirapongse ✭✭✭✭✭

    @dewi

    I assume that you are using the Databricks.

    I tested it on Azure Databricks and it works fine.

    image.png

    You may try to downgrade the httpx to 0.24.1 and then restart the environment.

    image.png
  • dewi
    dewi Newcomer

    I already following you setup session and downgrade the httpx, also restart the kernel but I got this error messages
    How to setup the session? Could you share the clearly documentation?

    image.png
  • dewi
    dewi Newcomer

    [Error 400] - {'error': 'access_denied'}Session is not opened. Can't send any requestValueError: Session is not opened. Can't send any request

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    The issue may be specific to your environment.

    Could you specify which Python environment or distribution you're currently using?

    You may try to test it on another environment.

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    @dewi

    Did the error change?

  • dewi
    dewi Newcomer

    the error change to this
    [Error 400] - {'error': 'access_denied'}Session is not opened. Can't send any requestValueError: Session is not opened. Can't send any request

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    It typically means that the credentials (user name and password) are incorrect.

    You can check your credentials by accessing this website (https://apidocs.refinitiv.com/Apps/ApiDocs).

    How did you solve the first issue (AttributeError: 'dict' object has no attribute 'url')?

  • dewi
    dewi Newcomer

    https://apidocs.refinitiv.com/Apps/ApiDocs
    when I access this link I got an authentication denied

  • dewi
    dewi Newcomer

    I follow step by step, username and password is correct but I got access denied

  • @dewi

    If you are getting authentication denied when using API Playground, this means that your credentials are incorrect.