locaweb / python-servicenow

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

.fetch_one fails with JSONDecodeError("Expecting value", s, err.value) Python 3.5 #32

Open shadycuz opened 7 years ago

shadycuz commented 7 years ago

raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

group = grp.fetch_one({'name': 'XXXXXXX'}) print(group)

ajayreddy28390 commented 7 years ago

shadycuz,

Did you fix above error?

shadycuz commented 7 years ago

No but I belive my problem was not having the correct service now API roles.

shadycuz commented 7 years ago

Or some other credential error.

ajayreddy28390 commented 7 years ago

I dont see as credential issue, as conn is successful.Might be API roles,not sure. Will see, if anyone else confirms same

inc = ServiceNow.Incident(conn)

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

print (inc)

<servicenow.ServiceNow.Incident object at 0x000001E401FEA8D0> inc = inc.fetch_one({'number': 'INC4578541'})

Only fetch_one issuing JSONDecodeError C:\Program Files\Anaconda3\lib\json\decoder.py in raw_decode(self, s, idx) 355 obj, end = self.scan_once(s, idx) 356 except StopIteration as err: --> 357 raise JSONDecodeError("Expecting value", s, err.value) from None 358 return obj, end

JSONDecodeError: Expecting value: line 1 column 1 (char 0)

amathur347 commented 6 years ago

I am getting the same error. Did anyone get a solution? i

kesavagithub commented 5 years ago

I am getting the same error. @wgrcunha Please advise. Error: ===================================== Traceback (most recent call last): File "/var/tmp/sxuevy/snowpoc/getIncDetails.py", line 19, in inci = inc.fetch_one({'number':'INC637935'}) File "/export/apps/citools/python/python-3.6.1/lib/python3.6/site-packages/servicenow/Utils.py", line 13, in caching return f(args, kwargs) File "/export/apps/citools/python/python-3.6.1/lib/python3.6/site-packages/servicenow/ServiceNow.py", line 29, in fetch_one response = self.fetch_all(meta, kwargs) File "/export/apps/citools/python/python-3.6.1/lib/python3.6/site-packages/servicenow/Utils.py", line 13, in caching return f(args, kwargs) File "/export/apps/citools/python/python-3.6.1/lib/python3.6/site-packages/servicenow/ServiceNow.py", line 21, in fetch_all return self.format(self.Connection._get(self.table, meta, kwargs)) File "/export/apps/citools/python/python-3.6.1/lib/python3.6/site-packages/servicenow/ServiceNow.py", line 54, in format return self.Connection._format(response) File "/export/apps/citools/python/python-3.6.1/lib/python3.6/site-packages/servicenow/Connection.py", line 116, in _format return json.loads(response.text) File "/export/apps/citools/python/python-3.6.1/lib/python3.6/json/init.py", line 354, in loads return _default_decoder.decode(s) File "/export/apps/citools/python/python-3.6.1/lib/python3.6/json/decoder.py", line 339, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/export/apps/citools/python/python-3.6.1/lib/python3.6/json/decoder.py", line 357, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) ===================================**

KCMiller1111 commented 5 years ago

It is not likely due to a connection as I'm getting the same error, and I'm opening it from my hard drive. My file is JSON formatted, so while it fails to load, a similar json file in the same location loads fine. I keep culling the file down to see if something in the file is causing a formatting error that makes it think there is a missing value, but no luck yet. When I recently did a straight json.load with the other file that does load, I got a warning: "InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised." Since my hard drive is shared with a OneDrive, I'm wondering if it's related to Office 365 and OneDrive since it has an external connection maybe a security patch just added to Office 365?

Gloix commented 5 years ago

For me the error was that I'm using a Kingston instance, and Dublin+ instances should use the JSONv2 api as stated in the readme file.