pronotepy icon indicating copy to clipboard operation
pronotepy copied to clipboard

Information.mark_as_read() raises PronoteAPIError

Open amiguet opened this issue 2 years ago • 8 comments

With this simplified code:

client = pronotepy.ParentClient(...)
objs = client.information_and_surveys()
objs[0].mark_as_read(True)

I get

Traceback (most recent call last):
  File ".../venv/lib/python3.10/site-packages/pronotepy/clients.py", line 684, in post
    return self.communication.post(function_name, post_data)
  File ".../venv/lib/python3.10/site-packages/pronotepy/pronoteAPI.py", line 184, in post
    raise PronoteAPIError(
pronotepy.exceptions.PronoteAPIError: Unknown error from pronote: 8 | La page a expiré ! (1)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File ".../pronotebridge.py", line 31, in <module>
    o.mark_as_read(True)
  File ".../venv/lib/python3.10/site-packages/pronotepy/dataClasses.py", line 933, in mark_as_read
    self._client.post("SaisieActualites", 8, data)
  File ".../venv/lib/python3.10/site-packages/pronotepy/clients.py", line 693, in post
    return self.communication.post(function_name, post_data)
  File ".../venv/lib/python3.10/site-packages/pronotepy/pronoteAPI.py", line 184, in post
    raise PronoteAPIError(
pronotepy.exceptions.PronoteAPIError: Unknown error from pronote: 20 | La page a expiré ! (11)

(there's also quite a bit of debug data, tell me if you need to know more).

Any idea what's happening?

amiguet avatar Oct 13 '22 19:10 amiguet

Hi, I'm not sure what could be the problem. Maybe it had a question in it that had to be filled? I could try and change marqueLueSeulement to true, but the web client does not do that. It currently works when I try it with the demo site.

bain3 avatar Nov 15 '22 20:11 bain3

No idea what the problem is. No question to answer, just plain text messages. Some have attachments, but the same error occurs whether there are attachments or not.

Tell me if you need more information to better understand what's happening.

In the meantime, I'm keeping a local list of digests of messages with a local read-status. Not ideal, but an acceptable workaround for my use case.

amiguet avatar Nov 19 '22 13:11 amiguet

Can you please try to catch the request that the browser makes when you click the "mark as read" button? The body of the request should have a "nom": "SaisieActualites" hopefully. Clicking the button fires two requests, it should be the first one.

image

The structure of the body of the request is the important bit. You can censor it all :)

bain3 avatar Nov 19 '22 14:11 bain3

Yes it fires two requests,the first of which contains a "nom": "SaisieActualites". The request seems much shorter in my case, though:

image

amiguet avatar Nov 19 '22 15:11 amiguet

Huh, not sure why your firefox does not parse the json inside donneesSec. Could you paste the contents of donneesSec here? Of course with personal info removed.

bain3 avatar Nov 19 '22 16:11 bain3

donneesSec is a long (672 chars) string of alphanumeric data (like 'c3fbdf9c971c61dac...'). Probably a hex encoding of some sort...

That probably explains why firefox doesn't parse it, but isn't very helpful otherwise, I'm afraid...

amiguet avatar Nov 19 '22 16:11 amiguet

Aha! That must be encrypted+compressed data then. Interesting... That is actually very helpful, because it means that pronotepy's encryption+compression works. Do all the requests look like that (are all donneesSec just a hex string)? They should, just checking.

bain3 avatar Nov 19 '22 16:11 bain3

Yes AFAICT they seem to all look like that.

amiguet avatar Nov 19 '22 21:11 amiguet