cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
conrad_perfett
Community Participant

Limiting courses from API to a particular Term

Jump to solution

Currently I am using a search term which seems to work since we prefix the sis course id with the term.

string CoursesUrl = @"https://texassouthmostcollege.test.instructure.com/api/v1/accounts/self/courses";

nvc2.Set("search_term", "2018SP");
client2.QueryString = nvc2;
byte[] responseBinary = client2.DownloadData(CoursesUrl);
string response = Encoding.UTF8.GetString(responseBinary);
courses = JsonConvert.DeserializeObject<List<Course>>(response);

Is this currently the only way to limit by term or is there another way I am missing a better way?

Advice is appreciated in this as I have very limited experience with using C# to access REST APIs

Tags (1)
1 Solution

Accepted Solutions
ColinMurtaugh
Community Champion

Hi Conrad --

Yes -- you can include the "enrollment_term_id" parameter to limit the results to a particular term. The value would be Canvas' numeric ID for the term you're looking for.  

There are a bunch of parameters that can be used with that API call to further filter/customize the results:

Accounts - Canvas LMS REST API Documentation 

Hope this helps!

--Colin

View solution in original post

4 Replies
ColinMurtaugh
Community Champion

Hi Conrad --

Yes -- you can include the "enrollment_term_id" parameter to limit the results to a particular term. The value would be Canvas' numeric ID for the term you're looking for.  

There are a bunch of parameters that can be used with that API call to further filter/customize the results:

Accounts - Canvas LMS REST API Documentation 

Hope this helps!

--Colin

View solution in original post

Thank you that was helpful.

For those experienced in this it may have seemed obvious but I guess what I was originally looking to use, was the actual SIS ID term value ie 2018SP etc but then I just realized, all I needed to do was read in the terms and just do a translation in the code!

 @conrad_perfett  

The term id is one that is you can refer to by its SIS ID. Adding the sis_term_id prefix to the query works for me.

enrollment_term_id=sis_term_id:2018SP

conrad_perfett
Community Participant

That worked even better. I can now simplify my code further and not read in the terms unnecessarily now. I was just not familiar with how some of these terms can be specified together.