locaweb / python-servicenow

Python Library to interact and manage the ServiceNow database
Apache License 2.0
96 stars 47 forks source link

json.decoder.JSONDecodeError #37

Open rohitjangid96 opened 5 years ago

rohitjangid96 commented 5 years ago
from servicenow import ServiceNow
from servicenow import Connection

# Connect using default api method (JSON)
conn = Connection.Auth(username='*****', password='*****', instance='cablevision')
inc = ServiceNow.Incident(conn)

inc = inc.fetch_one({'number': 'INC0665393'})

Traceback (most recent call last): File "C:/Users/rohitjan/PycharmProjects/AutomationScripts/sernow.py", line 10, in inc = inc.fetch_one({'number': 'INC0665393'}) File "C:\Users\rohitjan\PycharmProjects\AutomationScripts\venv\lib\site-packages\servicenow\Utils.py", line 13, in caching return f(args, kwargs) File "C:\Users\rohitjan\PycharmProjects\AutomationScripts\venv\lib\site-packages\servicenow\ServiceNow.py", line 29, in fetch_one response = self.fetch_all(meta, kwargs) File "C:\Users\rohitjan\PycharmProjects\AutomationScripts\venv\lib\site-packages\servicenow\Utils.py", line 13, in caching return f(args, kwargs) File "C:\Users\rohitjan\PycharmProjects\AutomationScripts\venv\lib\site-packages\servicenow\ServiceNow.py", line 21, in fetch_all return self.format(self.Connection._get(self.table, meta, kwargs)) File "C:\Users\rohitjan\PycharmProjects\AutomationScripts\venv\lib\site-packages\servicenow\ServiceNow.py", line 54, in format return self.Connection._format(response) File "C:\Users\rohitjan\PycharmProjects\AutomationScripts\venv\lib\site-packages\servicenow\Connection.py", line 116, in _format return json.loads(response.text) File "C:\Users\rohitjan\AppData\Local\Programs\Python\Python37-32\lib\json__init__.py", line 348, in loads return _default_decoder.decode(s) File "C:\Users\rohitjan\AppData\Local\Programs\Python\Python37-32\lib\json\decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "C:\Users\rohitjan\AppData\Local\Programs\Python\Python37-32\lib\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 1 (char 0)

nagyem commented 4 years ago

Did you ever find a solution?

alignedright commented 4 years ago

I had a similar issue, fixed by adding api='JSONv2":

For Dublin+ instances, connect using JSONv2 conn = Connection.Auth(username='edsu', password='bele', instance='servicenowsubdomain', api='JSONv2')