Update course start and end time time through API
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2023
05:03 PM
I am trying to write a program for my team to update course start and end times through the API using Python. The end_at time isn't updating. What am I doing wrong? I've code below for obvious reasons.
import requests
secret_token = "MY_SECRET_TOKEN"
headers = {'Authorization' : 'Bearer ' + secret_token}
pagesURL = 'MY_INSTITUTION/api/v1/courses/COURSE_ID'
r = requests.get(pagesURL,headers = headers)
i = r.json()
start = i["start_at"]
time = '2024-10-05T17:19:17Z'
end = {"course[end_at]":time}
data = requests.post(pagesURL,headers = headers, params = end)
print(start)
print(i['end_at'])
Solved! Go to Solution.
1 Solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2023
05:14 PM
Hi @bertscjn1,
A couple things jump out at me right away...
First, you're doing a post call, when to modify an existing course you want to use a put call.
Second, I'm confused by your print statements at the end. You're not changing the start time, so that doesn't matter too much. But when printing the end time, you're printing from i, which is going to have the original end time of the course, not your updated one. Unsure if that's intentional or not.
Adjusting those may help!
-Chris