cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
995
Views
5
Helpful
3
Replies

JSONDecodeError in SDWAN API response in Python

hrmt92
Level 1
Level 1

I am automating a task via the SDWAN API and whenever I request a response from methods like get_device_config or export_device_template_list, I get below error.

 

result_json = json.loads(response.text)
File "C:\Users\htmc0583\AppData\Local\Programs\Python\Python39\lib\json\__init__.py", line 346, in loads
return _default_decoder.decode(s)
File "C:\Users\htmc0583\AppData\Local\Programs\Python\Python39\lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:\Users\htmc0583\AppData\Local\Programs\Python\Python39\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)

 

The json that I am getting is not valid for some reason. Anybody faced the same issue and any solution to this?

3 Replies 3

@hrmt92 “json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)” can occur when you try to decode an empty string as JSON. This might occur when your code is accessing a web API and getting an empty response, reading a file with nothing in it, or simply passing an empty string to json.loads()

Please mark this as helpful or solution accepted to help others
Connect with me https://bigevilbeard.github.io

rohanupadhye01
Level 1
Level 1

Hello @hrmt92 did you get a solution to this problem??

If so can you please share the solution 

No @rohanupadhye01 , not yet. Alot of methods are working well but some just do not give validated json I think.

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: