POST Request and Rate Limit

SanyuktaLamsal
Community Novice

I am using the Canvas API to create folders and subfolders of courses that have been offered at my institution in the past. I used a simple Python script to do this and when I executed the code through my terminal, it reflected on the Canvas site. 

 

I tried to use this request to create a new folder with subfolders, but nothing was listed in my terminal (I had added lines to my script that would allow me to see which courses were added to the files and the JSON). I am wondering if I did something wrong within my code, or if I had hit the rate limit. 

 

Here is the code snippet below: 
 

for course in spring_2024_courses:
sils_folder_data = {
'name': course,
'parent_folder_path': 'Spring 2024'
}

response = requests.post(
f'{canvas_api_url}/courses/{course_id}/folders',
headers=headers,
json=sils_folder_data
)

if response.status_code == 201:
new_folder = response.json()
print(f'Created folder: {new_folder["name"]}')
else:
print(f'Failed to create folder: {response.status_code}')
print(response.text)
0 Likes