Finding course after creating it with REST-API

Jump to solution
JanTrinborg
Community Member

Hi!
So i have a case where i need to manually create about 100 courses and then add one teacher to each course. So i decided to do it via the REST-API using a python script.

Currently i have made the part of the python script that creates the courses by looping through a csv file and fill in the details needed to create the course. This part works like a charm.

The problem i have is that i now have to find the course again to add the teacher to the course. Adding the teachers after i have found the course shouldn`t be a problem, but i am a little uncertain about how to find the course i just created. Does anyone know a smart way to do this in the script?

 

- Jan Thomas

0 Likes
1 Solution
chriscas
Community Coach
Community Coach

Hi @JanTrinborg,

When you make successfully make a POST call to create a course, the API should return a course object, which will include the course id.  That course id is what you'd need for the subsequent enrollment call.  Personally, I'd have your code create a course, do the teacher enrollment(s), then move to the next line in your CSV and repeat.  If you create all the courses first before doing enrollments, you'll need to keep track of all of the course ids, which is doable but probably not ideal.

-Chris

View solution in original post