sijis / sumologic-python

Sumologic's python api library
Apache License 2.0
8 stars 5 forks source link

getting No JSON object could be decoded #5

Open Constantin07 opened 4 years ago

Constantin07 commented 4 years ago

Hi,

Trying to run this simple script in virtual environment on MacOS, Python 2.7.16

#!/usr/bin/env python

import os
from sumologic import Client, Collectors, Search

USENAME = os.environ['SUMOLOGIC_ACCESSID']
PASSWORD = os.environ['SUMOLOGIC_ACCESSKEY']

# Need a client to authenticate to service
client = Client(auth=(USENAME, PASSWORD))

# collector usage
collector = Collectors(client)
for c in collector.get_collectors():
    print('{0}:{1}'.format(c['name'], c['alive']))

and I'm getting this error:

Traceback (most recent call last):
  File "./script.py", line 14, in <module>
    for c in collector.get_collectors():
  File "/Users/user/Documents/SumoLogic/api/.venv/lib/python2.7/site-packages/sumologic/collectors.py", line 41, in get_collectors
    results = request.json()['collectors']
  File "/Users/user/Documents/SumoLogic/api/.venv/lib/python2.7/site-packages/requests/models.py", line 898, in json
    return complexjson.loads(self.text, **kwargs)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py", line 339, in loads
    return _default_decoder.decode(s)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 364, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 382, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded
pip freeze
certifi==2020.6.20
chardet==3.0.4
idna==2.10
requests==2.24.0
sumologic==0.1.4
urllib3==1.25.11

what am I doing wrong ? the credentials are valid.

sijis commented 4 years ago

I'll have to check. I haven't touched this code ina while.