python273 / telegraph

Telegraph API wrapper | Telegra.ph
https://pypi.org/project/telegraph/
MIT License
289 stars 45 forks source link

JSONDecodeError when edit page #47

Open Soulbadguy54 opened 1 year ago

Soulbadguy54 commented 1 year ago

Get error when simply try to edit page.

File "C:\Users\Soulbadguy\PycharmProjects\match_parsers\objects\telegraph.py", line 80, in _act_telegraph
    page = await func(**func_args)
  File "C:\Users\Soulbadguy\PycharmProjects\match_parsers\.venv\lib\site-packages\telegraph\aio.py", line 209, in edit_page
    return (await self._telegraph.method('editPage', path=path, values={
  File "C:\Users\Soulbadguy\PycharmProjects\match_parsers\.venv\lib\site-packages\telegraph\aio.py", line 32, in method
    response = (await self.session.post(
  File "C:\Users\Soulbadguy\PycharmProjects\match_parsers\.venv\lib\site-packages\httpx\_models.py", line 742, in json
    return jsonlib.loads(self.content.decode(encoding), **kwargs)
  File "C:\Users\Soulbadguy\AppData\Local\Programs\Python\Python39\lib\json\__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "C:\Users\Soulbadguy\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\Soulbadguy\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 args are right, the hltm content dont have any unclosed tags, but simply get this error...

The funniest thing consists in the fix for this problem. Just rerun and rerun the request without any changes. And at 5th or 6th try (ususally) the problem is fixed...

When i dont get error, i obviously get response.status 200 and json object as response. But sometimes i get 500 status with that NOT JSON body, that raise the exeption:

<html>
<head><title>500 Internal Server Error</title></head>
<body>
<center><h1>500 Internal Server Error</h1></center>
<hr><center>nginx/1.20.1</center>
</body>
</html>
ssuprun89 commented 1 year ago

10.02.2023 i receive 500 error all day Did you find the solution? @Soulbadguy54