I'm trying to create a program that gets all the students in a classroom and then checks each student indivually if the last assignment have been submitted or not but I always seem to get that the class id is wrong ( I got it using HTML inspect since it's not visible on google classroom itself ).
This is the code :
import googleapiclient.discovery
import google.oauth2.service_account
# Set the path to the JSON key file
JSON_KEY_FILE_PATH = 'E:\Computer Science A2\Past Papers P4\Variant 2\pythonProject/followup-system-400422-a994cd3df2c6.json'
# Create a Google Classroom API service object
credentials = google.oauth2.service_account.Credentials.from_service_account_file(JSON_KEY_FILE_PATH)
service = googleapiclient.discovery.build('classroom', 'v1', credentials=credentials)
# Get the students list
students = service.courses().students().list(courseId='626604275712').execute()['students']
# Get the last assignment
assignments = service.courses().courseWork().list(courseId='626604275712').execute()['courseWork']
last_assignment = assignments[0]
# Check if student X submitted code
student_x_submission = service.courses().courseWork().studentSubmissions().get(courseId='626604275712', courseWorkId=last_assignment['id'], userId='626603760934').execute()
if student_x_submission['status'] == 'TURNED_IN':
print('Student X submitted code for the last assignment.')
else:
print('Student X did not submit code for the last assignment.')
but I always get this error:
Traceback (most recent call last):
File "E:\Computer Science A2\Past Papers P4\Variant 2\pythonProject\main2.py", line 12, in <module>
students = service.courses().students().list(courseId='626604275712').execute()['students']
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\Computer Science A2\Past Papers P4\Variant 2\pythonProject\venv\Lib\site-packages\googleapiclient\_helpers.py", line 134, in positional_wrapper
return wrapped(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\Computer Science A2\Past Papers P4\Variant 2\pythonProject\venv\Lib\site-packages\googleapiclient\http.py", line 935, in execute
raise HttpError(resp, content, uri=self.uri)
googleapiclient.errors.HttpError: <HttpError 404 when requesting https://classroom.googleapis.com/v1/courses/626604275712/students?alt=json returned "Requested entity was not found.". Details: "Requested entity was not found.">
is there a way to get google classroom course id?