questrade_api icon indicating copy to clipboard operation
questrade_api copied to clipboard

json.decoder.JSONDecodeError: Expecting value: line 1 column 2 (char 1)

Open cr0n-dist0rti0n opened this issue 5 years ago • 2 comments

*** Error Output Below ***

File "/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/decoder.py", line 353, in raw_decode
  obj, end = self.scan_once(s, idx)

builtins.StopIteration: 1

During handling of the above exception, another exception occurred:

 File "/dowload_questrade_data/questrade/questrade_play.py", line 4, in <module>
  q = Questrade(refresh_token='<my token code>')
File "/usr/local/lib/python3.7/site-packages/questrade_api/questrade.py", line 22, in __init__
  self.auth = Auth(**auth_kwargs, config=self.config)
File "/usr/local/lib/python3.7/site-packages/questrade_api/auth.py", line 20, in __init__
  self.__refresh_token(kwargs['refresh_token'])
File "/usr/local/lib/python3.7/site-packages/questrade_api/auth.py", line 39, in __refresh_token
  token = json.loads(r.read().decode('utf-8'))
File "/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/__init__.py", line 348, in loads
  return _default_decoder.decode(s)
File "/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/decoder.py", line 337, in decode
  obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/decoder.py", line 355, in raw_decode
  raise JSONDecodeError("Expecting value", s, err.value) from None

json.decoder.JSONDecodeError: Expecting value: line 1 column 2 (char 1)

*** From 'decoder.py' ***

  def raw_decode(self, s, idx=0):
       """Decode a JSON document from ``s`` (a ``str`` beginning with
       a JSON document) and return a 2-tuple of the Python
       representation and the index in ``s`` where the document ended.

       This can be used to decode a JSON document from a string that may
       have extraneous data at the end.

       """
       try:
           obj, end = self.scan_once(s, idx)
       except StopIteration as err:
           raise JSONDecodeError("Expecting value", s, err.value) from None
       return obj, end

Issue with line 355: raise JSONDecodeError("Expecting value", s, err.value) from None

cr0n-dist0rti0n avatar Mar 08 '20 08:03 cr0n-dist0rti0n

I had this same issue come up on a Friday evening. After panicking and resetting all of my Questrade tokens, apps, etc, nothing worked. Went to sleep defeated. Saturday morning, however, everything was working again like it had been for the prior week. Perhaps a Questrade API server issue, but definitely not this Python pkg. In case anyone else finds this error, just breathe and sleep on it. Try it again tomorrow and refresh your tokens if you need.

Thanks to tgardiner for this pkg... it makes the API easier for a dummy like me!! MC

MikeCas avatar Nov 07 '20 16:11 MikeCas

Never had exactly this happen.

I'd account the occasional hiccup that goes away with time to server maintenance. Their login page may be up online on questrade.com, but their API backends might be down. This happened yesterday. The API backend wasn't up until this morning.

saskatchewancatch avatar Nov 15 '20 23:11 saskatchewancatch