Error in generatesession Couldn't parse the JSON response received from the server: b


  • My Code below

    from smartapi import SmartConnect
    obj = SmartConnect(api_key="JtgzY20m")

    data = obj.generateSession("MyClientID", "myPassword", 'myTOTP')
    refreshToken = data['data']['refreshToken']

    Getting error -->

    C:\Users\Administrator\AppData\Local\Programs\Python\Python38\python.exe "C:\Users\Administrator\Downloads\Telegram Desktop\smart_api_3\smart_api_3\ANGEL_IEOD_downlder.py"
    Traceback (most recent call last):
    File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\smartapi\smartConnect.py", line 188, in request
    data = json.loads(r.content.decode("utf8"))
    File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\json_init
    .py", line 357, in loads
    return _default_decoder.decode(s)
    File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
    File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\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)

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
    File "C:\Users\Administrator\Downloads\Telegram Desktop\smart_api_3\smart_api_3\ANGEL_IEOD_downlder.py", line 9, in <module>
    data = obj.generateSession("", "", '*****')
    File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\smartapi\smartConnect.py", line 228, in generateSession
    loginResultObject=self._postRequest("api.login",params)
    File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\smartapi\smartConnect.py", line 220, in _postRequest
    return self._request(route, "POST", params)
    File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\smartapi\smartConnect.py", line 191, in _request
    raise ex.DataException("Couldn't parse the JSON response received from the server: {content}".format(
    smartapi.smartExceptions.DataException: Couldn't parse the JSON response received from the server: b''

    Process finished with exit code 1

    somebody tell whats wrong ?