Skip to content
Bermudez, Jaime edited this page Jul 17, 2014 · 3 revisions

Copy the code below into a file called example.py (or whatever you want to call it) Replace the values for course_id, oauth_token, and canvas_url with your real values.

from canvas_sdk.methods import sections
from canvas_sdk import RequestContext

course_id = 12345    # needs to be replace with real value
oauth_token = 'secret_token'    # needs to be replace with real value
canvas_url = 'https://hostname/api'    # needs to be replace with real value

# init the request context
request_context = RequestContext(oauth_token, canvas_url)

results = sections.list_course_sections(request_context, course_id)
for idx, section in enumerate(results.json()):
     print "section %d has data %s" % (idx, section)

Then run:

$ python example.py

that's it!

Clone this wiki locally