API scripting with Python: How to set 'include[]' parameter?

Jump to solution
NathanArnold
Community Member

So, I'm hoping to get all submissions of a given assignment via Canvas API using a Python script.

Per this link: https://community.canvaslms.com/t5/Canvas-Question-Forum/Is-there-an-API-call-that-get-a-list-of-all...

...the solution is to set the Include[] parameter to 'submission_history'. But I'm not sure exactly how to do that when interfacing using Python (and specifically the requests library). I try setting the params this way, with no luck.

perpage = 100
params = {'per_page' : perpage, 'include[]' : 'submission_history'}

I also tried the above with

'include[]' : ['submission_history']

 That didn't work either. Obviously, when I call requests.get, I am setting params=params, and the change to the per_page parameter is working correctly. This is probably an issue with the syntax specific to the requests library, but I can't seem to find any info there. Hopefully someone here has wisdom for me 🙂

0 Likes
1 Solution
chriscas
Community Coach
Community Coach

Hi @NathanArnold,

I came across this unanswered question when doing a community cleanup.  While I haven't used that particular parameter before, I know you can just add things like that to the url as querystrings...  Ex https://school.instructure.com/api/v1/courses/:course_id/students/submissions?include[]=submission_h...

I hope this helps a bit!

-Chris

View solution in original post