I would like to print all users in my organization in GitHub using PyGitHub.
The below snippet works, however it returns a PaginatedList
:
python3 -c 'import os; from github import Github;g = Github(os.environ["TOKEN"]);
repo = g.get_repo("ORG/REPO");
organization = repo.organization;
members = organization.get_members(); print(members);'
However, when I want to print the PaginatedList
I'm getting an error:
python3 -c 'import os; from github import Github;g = Github(os.environ["TOKEN"]);
repo = g.get_repo("ORG/REPO"); organization = repo.organization;
members = organization.get_members(); print(members); [print(m) for m in members];'
And the error:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "<string>", line 1, in <listcomp>
File "/usr/local/lib/python3.10/dist-packages/PyGithub-1.55-py3.10.egg/github/PaginatedList.py", line 56, in __iter__
newElements = self._grow()
File "/usr/local/lib/python3.10/dist-packages/PyGithub-1.55-py3.10.egg/github/PaginatedList.py", line 67, in _grow
newElements = self._fetchNextPage()
File "/usr/local/lib/python3.10/dist-packages/PyGithub-1.55-py3.10.egg/github/PaginatedList.py", line 199, in _fetchNextPage
headers, data = self.__requester.requestJsonAndCheck(
File "/usr/local/lib/python3.10/dist-packages/PyGithub-1.55-py3.10.egg/github/Requester.py", line 353, in requestJsonAndCheck
return self.__check(
File "/usr/local/lib/python3.10/dist-packages/PyGithub-1.55-py3.10.egg/github/Requester.py", line 378, in __check
raise self.__createException(status, responseHeaders, output)
github.GithubException.UnknownObjectException: 404 {"message": "Not Found", "documentation_url": "https://docs.github.com/rest"}
I know I can do:
python3 -c 'import os; from github import Github;
g = Github(os.environ["TOKEN"]); organization = g.get_organization("ORG");
members = organization.get_members();
[print(member) for member in members]; '
But that's not the point, I need it the way I showed (which does not work).