Skip to content

Odd JSONDecodeError generated by API call  #27

@davidrpugh

Description

@davidrpugh

The following API call is throwing a JSONDecodeError.

data = pybea.get_data(USER_ID,
                      DataSetName='GDPbyIndustry',
                      Year='2010',
                      Industry=11,
                      TableID='ALL',
                      Frequency=['A', 'Q'],
                      )

Here is the traceback...

---------------------------------------------------------------------------
JSONDecodeError                           Traceback (most recent call last)
<ipython-input-47-a60ac2df9908> in <module>()
      4                       Industry=11,
      5                       TableID='ALL',
----> 6                       Frequency=['A', 'Q'],
      7                       )

~/Develop/pyBEA/pybea/pybea.py in get_data(UserID, DataSetName, ResultFormat, **params)
    202     if DataSetName in valid_dataset_names:
    203         tmp_request = api.DataRequest(UserID, DataSetName, ResultFormat, **params)
--> 204         df = pd.DataFrame(tmp_request.data, dtype=np.int64)
    205     else:
    206         raise ValueError("Invalid DataSetName requested.")

~/Develop/pyBEA/pybea/api.py in data(self)
    346     def data(self):
    347         if self['ResultFormat'] == 'JSON':
--> 348             tmp_data = self._json_data
    349         else:
    350             tmp_data = self._xml_data

~/Develop/pyBEA/pybea/api.py in _json_data(self)
    321     @property
    322     def _json_data(self):
--> 323         return self.results['Data']
    324 
    325     @property

~/Develop/pyBEA/pybea/api.py in results(self)
     88     def results(self):
     89         if self['ResultFormat'] == 'JSON':
---> 90             tmp_results = self._json_results
     91         else:
     92             tmp_results = self._xml_results

~/Develop/pyBEA/pybea/api.py in _json_results(self)
     60     @property
     61     def _json_results(self):
---> 62         raw_json = self._load_json_content()
     63         return raw_json['BEAAPI']['Results']
     64 

~/Develop/pyBEA/pybea/api.py in _load_json_content(self)
     94 
     95     def _load_json_content(self):
---> 96         return self.response.json()
     97 
     98     def _load_xml_content(self):

~/anaconda3/lib/python3.6/site-packages/requests/models.py in json(self, **kwargs)
    890                     # used.
    891                     pass
--> 892         return complexjson.loads(self.text, **kwargs)
    893 
    894     @property

~/anaconda3/lib/python3.6/json/__init__.py in loads(s, encoding, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
    352             parse_int is None and parse_float is None and
    353             parse_constant is None and object_pairs_hook is None and not kw):
--> 354         return _default_decoder.decode(s)
    355     if cls is None:
    356         cls = JSONDecoder

~/anaconda3/lib/python3.6/json/decoder.py in decode(self, s, _w)
    337 
    338         """
--> 339         obj, end = self.raw_decode(s, idx=_w(s, 0).end())
    340         end = _w(s, end).end()
    341         if end != len(s):

~/anaconda3/lib/python3.6/json/decoder.py in raw_decode(self, s, idx)
    353         """
    354         try:
--> 355             obj, end = self.scan_once(s, idx)
    356         except StopIteration as err:
    357             raise JSONDecodeError("Expecting value", s, err.value) from None

JSONDecodeError: Invalid control character at: line 1 column 31988 (char 31987)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions