RDError: Error code 0 | Error happened during config file ../Configuration\refinitiv-data.config.jso

When performing the tutorial for Refinitiv Data Library for Python I did all according to the suggestions. I created a config-file with the credentials (I checked: they are correct!) and in the Quickstart tutorial I tried QS_1.0 - Sessions.ipynb.
At the rd.open_session() statement I get a lot of errors, ending with the "RDError: Error code 0 | Error happened during config file ../Configuration\refinitiv-data.config.json read"
But the config file is in the path.

I have refinitiv data version 1.3.0.

I want a platform session.
This is the file refinitiv-data.config.json:

{

"logs": {

"level": "debug",

"transports": {

"console": {

"enabled": true

},

"file": {

"enabled": false,

"name": "refinitiv-data-lib.log"

}

}

},


"sessions": {

"default": "platform.rdp",
"platform": {

"rdp": {

"app_key": "53xxxxxxxxxxxxxxxx",
"username": "xxxxxxx",
"password": "xxxxxxxx"
},
},
"desktop": {

"workspace": {

"app-key": "YOUR APP KEY GOES HERE!"
}
}
}
}

So what is the reason for this problem?

---------------------------------------------------------------------------
JSONDecodeError Traceback (most recent call last)
File ~\anaconda3\envs\refinitiv\Lib\site-packages\refinitiv\data\_configure.py:91, in _read_config_file(path)
90 with open(path, "r") as f:
---> 91 data = json.load(f, cls=_JSONDecoder)
92 except FileNotFoundError:

File ~\anaconda3\envs\refinitiv\Lib\json\__init__.py:293, in load(fp, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
276 """Deserialize ``fp`` (a ``.read()``-supporting file-like object containing
277 a JSON document) to a Python object.
278
(...)
291 kwarg; otherwise ``JSONDecoder`` is used.
292 """
--> 293 return loads(fp.read(),
294 cls=cls, object_hook=object_hook,
295 parse_float=parse_float, parse_int=parse_int,
296 parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)

File ~\anaconda3\envs\refinitiv\Lib\json\__init__.py:359, in loads(s, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
358 kw['parse_constant'] = parse_constant
--> 359 return cls(**kw).decode(s)

File ~\anaconda3\envs\refinitiv\Lib\site-packages\refinitiv\data\_configure.py:140, in _JSONDecoder.decode(self, s, _w)
139 s = s.replace("\\", "\\\\")
--> 140 return super().decode(s, _w)

File ~\anaconda3\envs\refinitiv\Lib\json\decoder.py:337, in JSONDecoder.decode(self, s, _w)
333 """Return the Python representation of ``s`` (a ``str`` instance
334 containing a JSON document).
335
336 """
--> 337 obj, end = self.raw_decode(s, idx=_w(s, 0).end())
338 end = _w(s, end).end()

File ~\anaconda3\envs\refinitiv\Lib\json\decoder.py:353, in JSONDecoder.raw_decode(self, s, idx)
352 try:
--> 353 obj, end = self.scan_once(s, idx)
354 except StopIteration as err:

JSONDecodeError: Expecting property name enclosed in double quotes: line 23 column 9 (char 561)

The above exception was the direct cause of the following exception:

RDError Traceback (most recent call last)
Cell In[13], line 1
----> 1 rd.open_session()

File ~\anaconda3\envs\refinitiv\Lib\site-packages\refinitiv\data\_fin_coder_layer\session.py:43, in open_session(***failed resolving arguments***)
41 _definition = Definition
42 _load_config = load_config
---> 43 _config_object = get_config()
44 _set_default = set_default
45 return _open_session(**locals())

File ~\anaconda3\envs\refinitiv\Lib\site-packages\refinitiv\data\_config_functions.py:16, in get_config()
10 def get_config() -> RDConfig:
11 """
12 Returns
13 -------
14 config object
15 """
---> 16 return _get_config()

File ~\anaconda3\envs\refinitiv\Lib\site-packages\refinitiv\data\_configure.py:442, in get_config()
432 """
433 Gets the whole config or create it if it does not exist.
434
(...)
439
440 """
441 if _config is None:
--> 442 reload()
443 return _config

File ~\anaconda3\envs\refinitiv\Lib\site-packages\refinitiv\data\_configure.py:508, in reload()
495 _project_config_dir = os.environ.get(_RDPLIB_ENV_DIR) or os.getcwd()
496 _config_files_paths = [
497 c
498 for c in [
(...)
506 if c
507 ]
--> 508 _config = _create_rdpconfig(_config_files_paths)
509 _config.load = _load_config_from_file
511 _observer = None

File ~\anaconda3\envs\refinitiv\Lib\site-packages\refinitiv\data\_configure.py:110, in _create_rdpconfig(files_paths)
108 if isinstance(files_paths, str):
109 files_paths = [files_paths]
--> 110 configs = _create_configs(files_paths)
111 return _RDPConfig(*configs)

File ~\anaconda3\envs\refinitiv\Lib\site-packages\refinitiv\data\_configure.py:102, in _create_configs(files_paths)
100 def _create_configs(files_paths: List[str]):
101 config_from_dict = ext_config_mod.config_from_dict
--> 102 dicts = [_read_config_file(f) for f in files_paths] + [_config_defaults.config]
103 configs = [config_from_dict(d) for d in dicts]
104 return configs

File ~\anaconda3\envs\refinitiv\Lib\site-packages\refinitiv\data\_configure.py:102, in <listcomp>(.0)
100 def _create_configs(files_paths: List[str]):
101 config_from_dict = ext_config_mod.config_from_dict
--> 102 dicts = [_read_config_file(f) for f in files_paths] + [_config_defaults.config]
103 configs = [config_from_dict(d) for d in dicts]
104 return configs

File ~\anaconda3\envs\refinitiv\Lib\site-packages\refinitiv\data\_configure.py:95, in _read_config_file(path)
93 return {}
94 except Exception as exc: # noqa
---> 95 raise RDError(0, f"Error happened during config file {path} read") from exc
97 return _substitute_values(data, data)

RDError: Error code 0 | Error happened during config file ../Configuration\refinitiv-data

Best Answer

  • Jirapongse
    Answer ✓

    @torben1

    Thank you for reaching out to us.

    I checked the configurations with the JSON Formatter website.

    It reports this error.

    1688016856141.png

    Please remove a comma character at line 36.

    I hope that this information is of help.

Answers

  • Thank You very much. I removed the comma and now it works.

  • Hi,

    i've tried your solution but still the same problem except line 90.

    I'm using refinitiv workspace and created api.

    I hope someone can help me!


    thanks


    here is my configuration file:

    {

    "logs": {

    "level": "debug",

    "transports": {

    "console": {

    "enabled": false

    },

    "file": {

    "enabled": false,

    "name": "refinitiv-data-lib.log"

    }

    }

    }

    "sessions": {

    "default": "platform.rdp",

    "platform": {

    "rdp": {

    "signon_control":true

    "app-key": "baXXXXXXXXXX",

    "username": "XXXXXXXXXXXXXX",

    "password": "XXXXXXXXXXXXXXX"

    }

    "deployed": {

    "app-key": "baXXXXXXXXXX",

    "realtime-distribution-system": {

    "url" : "YOUR DEPLOYED HOST:PORT GOES HERE!",

    "dacs" : {

    "username" : "YOUR DACS ID GOES HERE!",

    "application-id" : 256,

    "position" : ""

    }

    }

    }

    }

    "desktop": {

    "workspace": {

    "app-key": "baXXXXXXXXXX"

    }

    }

    }

    }

    here is the log:


    ---------------------------------------------------------------------------
    JSONDecodeError Traceback (most recent call last)
    File ~\anaconda3\Lib\site-packages\refinitiv\data\_configure.py:90, in _read_config_file(path)
    89 with open(path, "r") as f:
    ---> 90 data = json.load(f, cls=_JSONDecoder)
    91 except FileNotFoundError:

    File ~\anaconda3\Lib\json\__init__.py:293, in load(fp, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
    276 """Deserialize ``fp`` (a ``.read()``-supporting file-like object containing
    277 a JSON document) to a Python object.
    278
    (...)
    291 kwarg; otherwise ``JSONDecoder`` is used.
    292 """
    --> 293 return loads(fp.read(),
    294 cls=cls, object_hook=object_hook,
    295 parse_float=parse_float, parse_int=parse_int,
    296 parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)

    File ~\anaconda3\Lib\json\__init__.py:359, in loads(s, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
    358 kw['parse_constant'] = parse_constant
    --> 359 return cls(**kw).decode(s)

    File ~\anaconda3\Lib\site-packages\refinitiv\data\_configure.py:132, in _JSONDecoder.decode(self, s, _w)
    131 s = s.replace("\\", "\\\\")
    --> 132 return super().decode(s, _w)

    File ~\anaconda3\Lib\json\decoder.py:337, in JSONDecoder.decode(self, s, _w)
    333 """Return the Python representation of ``s`` (a ``str`` instance
    334 containing a JSON document).
    335
    336 """
    --> 337 obj, end = self.raw_decode(s, idx=_w(s, 0).end())
    338 end = _w(s, end).end()

    File ~\anaconda3\Lib\json\decoder.py:353, in JSONDecoder.raw_decode(self, s, idx)
    352 try:
    --> 353 obj, end = self.scan_once(s, idx)
    354 except StopIteration as err:

    JSONDecodeError: Expecting ',' delimiter: line 14 column 5 (char 278)

    The above exception was the direct cause of the following exception:

    RDError Traceback (most recent call last)
    Cell In[8], line 1
    ----> 1 rd.open_session()

    File ~\anaconda3\Lib\site-packages\refinitiv\data\_access_layer\session.py:45, in open_session(***failed resolving arguments***)
    42 config_object = load_config(config_name)
    44 else:
    ---> 45 config_object = get_config()
    47 name = config_path or config_object.get_param("sessions.default")
    49 try:

    File ~\anaconda3\Lib\site-packages\refinitiv\data\_configure.py:534, in get_config()
    528 """
    529 Returns
    530 -------
    531 config object
    532 """
    533 if _config is None:
    --> 534 reload()
    535 return _config

    File ~\anaconda3\Lib\site-packages\refinitiv\data\_configure.py:486, in reload()
    473 _project_config_dir = os.environ.get(_RDPLIB_ENV_DIR) or os.getcwd()
    474 _config_files_paths = [
    475 c
    476 for c in [
    (...)
    484 if c
    485 ]
    --> 486 _config = _create_rdpconfig(_config_files_paths)
    487 _config.load = _load_config_from_file
    489 _observer = None

    File ~\anaconda3\Lib\site-packages\refinitiv\data\_configure.py:461, in _create_rdpconfig(files_paths)
    459 if isinstance(files_paths, str):
    460 files_paths = [files_paths]
    --> 461 configs = _create_configs(files_paths)
    462 return _RDPConfig(*configs)

    File ~\anaconda3\Lib\site-packages\refinitiv\data\_configure.py:101, in _create_configs(files_paths)
    99 def _create_configs(files_paths: List[str]):
    100 config_from_dict = ext_config_mod.config_from_dict
    --> 101 dicts = [_read_config_file(f) for f in files_paths] + [_config_defaults.config]
    102 configs = [config_from_dict(d) for d in dicts]
    103 return configs

    File ~\anaconda3\Lib\site-packages\refinitiv\data\_configure.py:101, in <listcomp>(.0)
    99 def _create_configs(files_paths: List[str]):
    100 config_from_dict = ext_config_mod.config_from_dict
    --> 101 dicts = [_read_config_file(f) for f in files_paths] + [_config_defaults.config]
    102 configs = [config_from_dict(d) for d in dicts]
    103 return configs

    File ~\anaconda3\Lib\site-packages\refinitiv\data\_configure.py:94, in _read_config_file(path)
    92 return {}
    93 except Exception as exc: # noqa
    ---> 94 raise RDError(0, f"Error happened during config file {path} read") from exc
    96 return _substitute_values(data, data)

    RDError: Error code 0 | Error happened during config file ../Configuration\refinitiv-data.config.json read
  • @fabrice02

    How did you get this configuation file?

    You can check it with the online tool, such as the JSON Formatter website.

    I checked the file and found that this is not a valid JSON format. There are few places that miss the colon characters.

    {
      "logs": {
        "level": "debug",
        "transports": {
          "console": {
            "enabled": false
          },
          "file": {
            "enabled": false,
            "name": "refinitiv-data-lib.log"
          }
        }
      },
      "sessions": {
        "default": "platform.rdp",
        "platform": {
          "rdp": {
            "signon_control": true,
            "app-key": "baXXXXXXXXXX",
            "username": "XXXXXXXXXXXXXX",
            "password": "XXXXXXXXXXXXXXX"
          },
          "deployed": {
            "app-key": "baXXXXXXXXXX",
            "realtime-distribution-system": {
              "url": "YOUR DEPLOYED HOST:PORT GOES HERE!",
              "dacs": {
                "username": "YOUR DACS ID GOES HERE!",
                "application-id": 256,
                "position": ""
              }
            }
          }
        },
        "desktop": {
          "workspace": {
            "app-key": "baXXXXXXXXXX"
          }
        }
      }
    }

    You can get the sample file from GitHub.

  • @Jirapongse I used the JSON configuration included in refinitiv library, now i've corrected the configuration file with all commas, (thanks! :-))


    another error comes:


    ---------------------------------------------------------------------------
    KeyError Traceback (most recent call last)
    File ~\anaconda3\Lib\site-packages\refinitiv\data\_configure.py:302, in _RDPConfig.get_param(self, param)
    301 try:
    --> 302 return self[param]
    303 except KeyError:

    File ~\anaconda3\Lib\site-packages\refinitiv\data\_external_libraries\python_configuration\configuration_set.py:102, in ConfigurationSet.__getitem__(self, item)
    101 def __getitem__(self, item: str) -> Union[Configuration, Any]: # noqa: D105
    --> 102 return self._from_configs("__getitem__", item)

    File ~\anaconda3\Lib\site-packages\refinitiv\data\_external_libraries\python_configuration\configuration_set.py:59, in ConfigurationSet._from_configs(self, attr, *args, **kwargs)
    57 if not values:
    58 # raise the last error
    ---> 59 raise last_err
    60 if all(isinstance(v, Configuration) for v in values):

    File ~\anaconda3\Lib\site-packages\refinitiv\data\_external_libraries\python_configuration\configuration_set.py:53, in ConfigurationSet._from_configs(self, attr, *args, **kwargs)
    52 try:
    ---> 53 values.append(getattr(config_, attr)(*args, **kwargs))
    54 except Exception as err:

    File ~\anaconda3\Lib\site-packages\refinitiv\data\_external_libraries\python_configuration\configuration.py:133, in Configuration.__getitem__(self, item)
    132 if v == {}:
    --> 133 raise KeyError(item)
    134 if isinstance(v, dict):

    KeyError: 'sessions.platform.rpd'

    During handling of the above exception, another exception occurred:

    AttributeError Traceback (most recent call last)
    File ~\anaconda3\Lib\site-packages\refinitiv\data\_access_layer\session.py:50, in open_session(name, app_key, config_name)
    49 try:
    ---> 50 config_object.get_param(f"sessions.{name}")
    51 except Exception:

    File ~\anaconda3\Lib\site-packages\refinitiv\data\_configure.py:304, in _RDPConfig.get_param(self, param)
    303 except KeyError:
    --> 304 raise AttributeError(f"Config object doesn't has '{param}' attribute")

    AttributeError: Config object doesn't has 'sessions.platform.rpd' attribute

    During handling of the above exception, another exception occurred:

    NameError Traceback (most recent call last)
    Cell In[4], line 1
    ----> 1 rd.open_session()

    File ~\anaconda3\Lib\site-packages\refinitiv\data\_access_layer\session.py:53, in open_session(name, app_key, config_name)
    51 except Exception:
    52 config_name = f" {config_name}" if config_name else ""
    ---> 53 raise NameError(
    54 f"Cannot open session {name}\nThis session is not defined in the{config_name} configuration file"
    55 )
    57 if app_key:
    58 config_object.set_param(param=f"sessions.{name}.app-key", value=app_key, auto_create=True)

    NameError: Cannot open session platform.rpd
    This session is not defined in the configuration file