I need to search courses through the Canvas API by the courses' context.Id values, but don't know the proper syntax. Does anyone know how to do this?
Hi Jake Ramsey,
Sorry I'm not too aware in this area aside from the documentation listed in the Canvas LMS REST API Documentation. I'll go ahead and share this with the Canvas Developers group for more exposure, though!
I'm not entirely clear on what you're trying to accomplish. If you know the course context ID, then you don't need to search for the course, you can load it directly.
If by context_id, you mean something like course_1234, then you split it on the underscore and the context is the first part while the id is the second part. Then you can look up the course using the Get a single course endpoint of the Courses API.
You replace that :id with the 1234 that you obtained when you split the context code.
If you mean something else, could you provide more information about you're trying to accomplish?
Hi James. Thanks for replying! Just to clarify, I work for an education company (Tutor.com), and we've integrated our service with a variety of clients' Canvas sites as an external app. Each time our external app link is clicked by an eligible student user, our clients' Canvas sites pass us a variety of LTI parameters, including context parameters intended to help identify the course from which a given student is accessing the external app. Here's an example:
LTI paramter Value1 context_id a3c96ab20c7f216effe38dee53e41507d93f6bf72 context_label AL101 Basic Nutrition, Kerin - FA17S33 context_title AL101 Basic Nutrition, Kerin - FA17S3
In one of our implementations, up to now, we've been recording the opaque context_id value from each transaction only (eg, a3c96ab20c7f216effe38dee53e41507d93f6bf7) and discarding the rest. We've now updated the LTI configuration for this implementation to record the context_label value instead, and it's working fine on a going-forward basis. However, we'd also like to update out legacy data, replacing each context_id value from old transactions with the corresponding context_label value. However, our client's LMS folks aren't sure how to look up courses by context_id, which they need to do in order to tell us which context_id should be overwritten by which context_label.
Jake Ramsey, sorry I missed your reply 4 months ago. Thanks Chris for bringing it back up.
Knowing that you're talking about LTI changes the game. Typically those opaque IDs have been difficult to impossible to get out of Canvas. The intent was that it is opaque and does not leak any information outside the system, which may help explain why it's hard to get that information.
I don't remember those IDs being available in Canvas Data, which might be the fastest way to find the information, but I wanted to double check before I said for sure. I have a testing LTI that basically dumps all of the information that Canvas sends with an LTI launch. I then looked inside every flat file in our Canvas Data instance, except for the requests tables, trying to find a match. I looked for context_id, ext_lti_assignment_id, lis_result_sourcedid, resource_link_id, and user_id --- all without success.
In the last year (I think), Canvas just made the user's LTI ID available through the REST API. It's under the Get user profile endpoint. But it's only returned when the person making the API call is the owner of the profile. Someone would have to masquerade as each user to get their LTI user ID opaque token. It's not searchable, so you would need to iterate through every user and compile their own copy of the information and then do a reverse lookup on the local copy of IDs.
That still doesn't help you because you want the course context_id, not the user_id.
In other words, short of someone launching the LTI from within each course, or using the LTI to invoke a sessionless launch of the API tool from every course that uses the tool so that you can collect the information on your side, you're probably not going to be able to collect that information from previous courses.
It's certainly not going to be easy for your clients to provide you with this information.
On a related note, if you haven't seen it, you may want to read the recent blog post by Jesse Poulos called LTI User/enrollment provisioning and synchronization
Hi Jake Ramsey...
As I was looking through older questions here in the Canvas Community, I saw that there hasn't been much activity in this topic since your reply on October 3, 2017. Although I don't have an answer for you myself, is this still an on-going issue? Have you found a solution? It looks like you and James Jones have been working through this. If you could please come back to provide an update, that would be helpful. Also, if you feel that one of the above responses can be marked "Correct", please feel free to do that. Otherwise, let us know if there are any related questions you still have. For now, I am going to mark your question as "Assumed Answered" because we've not seen any new activity in this thread for a few months. This won't prevent you or others from posting additional questions and/or comments below, however. I hope that's alright with you, Jake. Looking forward to your reply.
Retrieving data ...