AnsweredAssumed Answered

Canvas API/Python Help - POST Requests

Question asked by Jason Kocur on Oct 24, 2019
Latest reply on Oct 29, 2019 by Brian Bennett

Hi Everyone!


I hope you are all doing well! I have recently started learning python and have admin access to our universities API. However, I have been finding it challenging to do some of the basic tasks that could help create efficiencies by automating things. I am able to pull some basic reports, but what I'm really looking for is how to send POST requests to update things like Quiz Extensions, as an example. It doesn't seem like there is anything out there on how to translate the Canvas API documentation into python. As a result of my guesses, I keep ending up with a 422 error code. The example below shows a what I have gotten so far, if anyone has a suggestion, that would be amazing!


# Use Python to POST Quiz Extentions to CANVAS API

# Import libraries
import requests
import json

# Headers(token)

headers = {
'Authorization': 'Bearer <token>'

payload = {
"quiz_extensions": [{
"user_id": 72448,
"extra_attempts": 2,
"manually_unlocked": True


payload_json = json.dumps(payload)

api_url = 'https://<school>'

# Requests
r =, data = payload_json, headers = headers)