-
Notifications
You must be signed in to change notification settings - Fork 2
/
getcourseragrades.py
40 lines (32 loc) · 1.2 KB
/
getcourseragrades.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import requests
# Replace 'your_access_token' with the actual token you received
access_token = ''
# Replace 'org_id' with the actual organization ID you want to retrieve details for
org_id = 'C894LttMQcGS3Kv6nSRPVQ'
# Endpoint URL
url = f"https://api.coursera.com/ent/api/businesses.v1/{org_id}/courseGradebookReports"
# Query parameters
params = {
'q': 'search',
'emailOrExternalId': '[email protected]', # Optional
'includeDeletedMembers': 'true', # Optional
'start': '0', # Optional, default is 0
'limit': '100' # Optional, default is 50
}
# Headers
headers = {
"Authorization": f"Bearer {access_token}",
"Content-Type": "application/json"
}
# Make the GET request
response = requests.get(url, headers=headers, params=params)
print(response.json())
# Check the response status code
if response.status_code == 200:
print("Course gradebook reports retrieved successfully")
course_gradebook_reports = response.json()
print(course_gradebook_reports)
else:
print("Failed to retrieve course gradebook reports")
print(f"Status code: {response.status_code}")
print(response.json())