Hey. I'm trying to loop through a csv file to enroll students into a course but I keep getting a 404 error. Can anyone give me some advice as to why? When I switch the request method to GET from POST I get a 200 status code. I've been staring at this for a while now so maybe I'm over looking something?
Column Headers from the CSV file: | record | course_id | user_id | role | status |
___________________________________________________________
import numpy as np
import pandas as pd
import requests
import json
dataset = pd.read_csv("PATH_TO_CSV_FILE")
df = pd.DataFrame.from_records(dataset)
ndarray = df.to_numpy()
secret_token = [MY API KEY]
headers = {'Authorization' : 'Bearer ' + secret_token}
courseID = [MY COURSE ID NUMER]
url = "https://[MY INSTITUTION].instructure.com/api/v1/courses/" + str(courseID) + "/enrollments" course = ""
for x in ndarray:
course = x[2]
print(course)
payload = {'enrollment[user_id]': course, 'enrollment[course_section_id]' : courseID}
r = requests.post(url,headers = headers, params = payload)
print(r.status_code)