Showing results for 
Show  only  | Search instead for 
Did you mean: 
New Member

API - course_id has a '/' in it

I've finally been allowed a crack at the API and have managed to get data back, but I've hit a problem where the course_Id is a code with a '/' in it (eg: BYMAN/201718) and I don't know how to pass that to the API. There are other courses that are just '12201' which is easy to pass (obviously) but I've tried multiple methods to try to pass it and I'm just not winning Smiley Sad. Does anyone else have this problem?

5 Replies
Community Champion

 @bsmith14 ,

Without testing your specific case (we don't have any slashes) ...

The standard way of including special characters is to URI encode them. There is a list of delimiters, but each scheme is able to treat them differently. For URLs, you should also escape ? and #. The list includes [ ] as well, but when you're doing query parameters like include[] that contain the [] to indicate an array, I do not encode those.

The / is %2F so you would write BYMAN%2F201718. According to RFC 3986, percent encoding is not case-sensitive so you could use %2f or %2F. However, there is a note that says, "for consistency, URI producers and normalizers should use uppercase hexadecimal digits for all percent-encodings."

By the way, that is most likely not the course ID. The course ID is an integer. That might be the SIS course ID, in which case you would need to use sis_course_id:BYMAN%2F201718.

If you are use JSON for your payload, then you don't have to encode the / as it's already within a string. What I'm describing is for items included in the URI, which includes the path and any query parameters. 

Community Champion

By the way -- congrats on getting access to the API! Now you'll actually be able to accomplish something and not keep running into the "it's not in Canvas Data" roadblocks.

If you're not part of the Canvas Developers‌ group, you'll probably want to join it. There's lots of code and answers there about about to use the API, including some resources about how to get started with the API.

New Member

Thanks James - I think I need to head back to the drawing board for a while. I believe I'm getting my lines crossed with sis_id and course_id... sys_id being what is displayed on the course page, and course_id which is what is passed to the API.

311405_Activate sis_id.png

311406_activate powershell.png

The above API call does return data for 13808, but there is no way that I can pass the API the 5CFCTEA00R/181901.  %2F gives the same errors, which makes me question what it is that I'm supposed to be using.

Thank you for your patience.

Community Champion

Did you try /api/v1/courses/sis_course_id:5CFCTEA00R%2F181901/enrollments ?

The 13808 should not be returning information unless you have a course_id with that is numbered 13808. I suppose that it is possible that your SIS IDs match your Canvas Course IDs, but you would likely need to create them in Canvas, see what number you got, and then add that as the SIS ID for that to happen. That's a very strange way of doing things, but I guess that it could be set up that way. It would preclude using SIS imports since they need the SIS ID as part of the import, but it could happen if you were creating courses through the API.

New Member

Feedback Note:

Thank you everyone for all the help. I have managed to resolve this (almost) completely by doing the following:

In my PowerShell script I have returned all the canvas_id's from the Course_dim table and then pass them one at a time to the API

The results are then saved into a csv file which I then import into my database - ready to report on with PowerBI.

The higher-ups have the data that they wanted and I'm working on a way to improve both the process and the script so that it can do a lot more.