Hi, I work in analytics for my institution.
I currently have a script that downloads all student analysis reports through the Canvas API, but it throws an exception about every 5GB of data because a download url isn't always provided when requested. It should also be noted that this error isn't consistent. The same request that doesn't provide a download url in one instance may provide a download url in another instance. My script works as followed:
Step 1:
I make a post request to begin generation of a student analysis report
POST /api/v1/courses/:course_id/quizzes/:quiz_id/reports?quiz_report[report_type]=student_analysis
The post request returns a progress url where I can check on the generation progress of the file
Step 2:
I make a get request with the progress url every half second to see if completion is 100%
POST /api/v1/progress/some_id
Step 3:
After completion is 100%, I repeat step 1 except I use a get request instead of a post request.
Get /api/v1/courses/:course_id/quizzes/:quiz_id/reports?quiz_report[report_type]=student_analysis
From this get request, I can access the json and get the download url by accessing the dictionary in the "file" value and then accessing the "url" value inside that dictionary.
However, once in a great while there is no "file" key. This results in my program trying to access a null value, which throws an exception. If anyone has any guidance on why this occurs sometimes, I would be very grateful. Have a great day!
This discussion post is outdated and has been archived. Please use the Community question forums and official documentation for the most current and accurate information.