Advertisement
Guest User

Python Create Course

a guest
Jul 2nd, 2015
365
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.58 KB | None | 0 0
  1. import requests
  2.  
  3. token=''
  4. def createNewCourse(title, code):
  5.     payload = {'course[account_id]' : 'AccountIDGoesHere',
  6.                'course[name]' : 'TitleGoesHere',
  7.                'course[course_code]': 'CourseCodeHere',
  8.                'offer' : 'TrueOrFalse'}
  9.     newCourseRequest = requests.post('https://xxxxx.instructure.com/api/v1/accounts/97825/courses', params = payload, headers = {'Authorization': 'Bearer ' + '%s' % token})
  10.     newCourseResponse = newCourseRequest.json()
  11.     print "The new course id is: " + str(newCourseResponse[u'id'])
  12.     print "The new course's name is: " +    str(newCourseResponse[u'name'])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement