Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get teachers for period #7

Closed
XDjackieXD opened this issue Nov 14, 2016 · 10 comments
Closed

Get teachers for period #7

XDjackieXD opened this issue Nov 14, 2016 · 10 comments

Comments

@XDjackieXD
Copy link

XDjackieXD commented Nov 14, 2016

When trying to request teachers for a period (period.teachers) I get an jsonrpc error telling me that I don't have permissions but the untis mobile app and webuntis are able to show teachers for a period.
It seems like the API changed a few weeks ago. the same script was working about 2 months ago

The exact error is

Traceback (most recent call last):
  File "/usr/lib/python3.5/site-packages/webuntis/utils/remote.py", line 102, in _parse_result
    return result_body[u'result']
KeyError: 'result'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "./Stundenplan.py", line 51, in <module>
    for teach in period.teachers:
  File "/usr/lib/python3.5/site-packages/webuntis/utils/misc.py", line 28, in __get__
    obj.__dict__[self.__name__] = result = self.fget(obj)
  File "/usr/lib/python3.5/site-packages/webuntis/objects.py", line 263, in teachers
    return self._session.teachers(from_cache=True).filter(
  File "/usr/lib/python3.5/site-packages/webuntis/utils/misc.py", line 143, in inner
    data = self._request(jsonrpc_method, jsonrpc_args)
  File "/usr/lib/python3.5/site-packages/webuntis/session.py", line 116, in _request
    data = rpc_request(self.config, method, params or {})
  File "/usr/lib/python3.5/site-packages/webuntis/utils/remote.py", line 84, in rpc_request
    return _parse_result(request_body, result_body)
  File "/usr/lib/python3.5/site-packages/webuntis/utils/remote.py", line 104, in _parse_result
    _parse_error_code(request_body, result_body)
  File "/usr/lib/python3.5/site-packages/webuntis/utils/remote.py", line 123, in _parse_error_code
    request_body
webuntis.errors.RemoteError: [Errno no right for getTeachers()] {'jsonrpc': '2.0', 'error': {'code': -8509, 'message': 'no right for getTeachers()'}, 'id': '2016-11-14 14:09:33.522419'}: {'params': {}, 'jsonrpc': '2.0', 'method': 'getTeachers', 'id': '2016-11-14 14:09:33.522419'}

Edit: I tried with the latest version of python-webuntis directly from git too with exactly the same error

@basti-schr
Copy link

Yes, I have the same problem as well! The reason, why you see the teachers in the official Untis Mobile App is, that they do not use the public API, they use an intern. You can see it, if you debug you phone and open untis. It calls /WebUntis/jsonrpc**_intern**.do ! Try the App SchoolPlaner4Untis! This is using the public API and it is on GitHub.

@XDjackieXD
Copy link
Author

SchoolPlanner has exactly the same Problem... Maybe I'll start reversing the internal API...

@AugustH AugustH closed this as completed Jul 23, 2020
@giddyhup
Copy link

@XDjackieXD did you find a solution or workaround? I only started getting the error recently.

@XDjackieXD
Copy link
Author

As I'm not in school anymore since a few years and my university doesn't use Untis, I haven't looked into this further.
It seems to be some Server side permission thing.
You could look into the communication between the Untis app and the server (using tools like mitmproxy for example) and try to use this API (best case it's the same API but using some special API token, worst case it's something completely different)

@giddyhup
Copy link

@XDjackieXD thank you for your quick response. I'll give up, for my use-case it's too much effort to try to reverse-engineer the official API.

@AugustH
Copy link
Collaborator

AugustH commented Sep 16, 2022

you can ask your untis-admin to give you this right. or look for the non-official, undocumented and unstable(?) API e.g. BetterUntis or SchoolPlanner4Untis

@giddyhup
Copy link

Thanks for replying. I will try to explain to the teacher who administrates the accounts what I am doing (parsing a day's schedule and display it on an epaper display), and why I would like him to change some rights for my login. I don't know the admin interface and if this is easy feasible but I'll find out.

@AugustH
Copy link
Collaborator

AugustH commented Sep 17, 2022

just pushed a new version, see https://python-webuntis.readthedocs.io/en/latest/quickstart.html for a list of needed rights.

epaper sounds great, have tried this with my students. Pull request with finished code as an example welcome...

@giddyhup
Copy link

Thanks. The responsible teacher confirmed that there were changes made by the provider but he can't grant more rights for the ID used by me. There may also be some reservations since it sounds like I want to get private teachers' data ("getTeachers()").

I tried to script my way through the web interface but it doesn't work without Javascript.

My workflow is very specific so sharing wouldn't help but the adapted code to upload a generated image from a Raspberry Pi to the display can be found here.

@giddyhup
Copy link

For posterity, here's what I did to keep some functionality. In my code I commented out all parts dealing with teachers. Regrettably, this means I have no way to become aware of teacher changes but at least subject and room changes can still be dealt with.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants