Forums

Error: simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Hello.

For a couple of weeks, I was running a script for a online game that would basically send notifications through Telegram. However, I now want to run it 24/7 so I decided to try pythonanywhere for 1 month.

The problem is that when I can run it locally perfectly but I get the following error when trying to run it on pythonanywhere:

    Traceback (most recent call last):
  File "/home/legends1337/OgameCruiser/start_bot.py", line 68, in <module>
    client.login()
  File "/home/legends1337/OgameCruiser/ogame/game/client.py", line 117, in login
    game_sess = self._get_game_session(game_env_id, platform_game_id)
  File "/home/legends1337/OgameCruiser/ogame/game/client.py", line 721, in _get_game_session
    game_sess = response.json()
  File "/home/legends1337/.local/lib/python3.9/site-packages/requests/models.py", line 898, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/simplejson/__init__.py", line 525, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.9/site-packages/simplejson/decoder.py", line 370, in decode
    obj, end = self.raw_decode(s)
  File "/usr/local/lib/python3.9/site-packages/simplejson/decoder.py", line 400, in raw_decode
    return self.scan_once(s, idx=_w(s, idx).end())
simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Traceback (most recent call last):
  File "/home/legends1337/OgameCruiser/start_bot.py", line 68, in <module>
    client.login()
  File "/home/legends1337/OgameCruiser/ogame/game/client.py", line 117, in login
    game_sess = self._get_game_session(game_env_id, platform_game_id)
  File "/home/legends1337/OgameCruiser/ogame/game/client.py", line 721, in _get_game_session
    game_sess = response.json()
  File "/home/legends1337/.local/lib/python3.9/site-packages/requests/models.py", line 898, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/simplejson/__init__.py", line 525, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.9/site-packages/simplejson/decoder.py", line 370, in decode
    obj, end = self.raw_decode(s)
  File "/usr/local/lib/python3.9/site-packages/simplejson/decoder.py", line 400, in raw_decode
    return self.scan_once(s, idx=_w(s, idx).end())
simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

And this is the part of the code that is causing the problem:

def _get_game_session(self, game_env_id, platform_game_id):
    response = self._request(
        method='post',
        url='https://gameforge.com/api/v1/auth/thin/sessions',
        delay=0,
        headers={'content-type': 'application/json'},
        json={'autoGameAccountCreation': False,
              'gameEnvironmentId': game_env_id,
              'gfLang': self.language,
              'identity': self.username,
              'locale': self.locale,
              'password': self.password,
              'platformGameId': platform_game_id})
    game_sess = response.json()
    if 'error' in game_sess:
        raise ValueError(game_sess['error'])
    return game_sess

I tried to put response.text to see what is the response and it seems to be empty...

When printing response.status_code and response.raise_for_status() I get 409 and requests.exceptions.HTTPError: 409 Client Error: Conflict for url: https://gameforge.com/api/v1/auth/thin/sessions respectively.

Shall I understand that pythonanywhere does not allow the connection to gameforge? I thought that by upgrading to a paid account there will be no whitelisting anymore.

Many thanks in advance,

Legends1337

We are not blocking you. You have to ask gameforge.