Have a question about the Canvas APIs? Have a cool API integration you'd be willing to share? If so, please post here.
Thanks Martin. Actually the folder looks like works correctly for me, Since from UI, I could see the folder was created after the POST request was completed (no matter there's a space in the folder name or not). The issue is the name of the file wasn't passed in via my POST.
Thanks,
Hi all!
Is anyone using the CalendarEvents API to synchronize a Canvas course calendar with an external source such as a Curriculum DB?
We have a curriculum database with information on all sessions (type, title, description) and offerings (location, time, section, and instructors). I'm considering the best way to handle this as we migrate from Sakai... Right now, here is my thought:
INITIAL LOAD - Course events are created using the API and the internal ID for the Curriculum Database gets appended to the event description for all events.
MODIFICATIONS - When someone changes the details of one of these events in the CurriculumDB, it uses the API to update that event in Canvas. If the event was getting deleted, delete it in Canvas
NIGHTLY - Get the list of all events for the course and then iterate, looking for the internalID in the description. Compare the event coming from Canvas with what is currently in the CurriculumDB. If different, update. If the same, do nothing. If it doesn't exist in the CurriculmDB, delete it. If it doesn't exist in Canvas, create it.
Ok -- now the 2nd question -- is anyone doing anything to PREVENT the teachers from editing these type of 'provided' calendar events? We don't want them to think that they can just change the date/time/location of an event... But -- at the same time, we DO want them to be able to create/edit/delete ad-hoc calendar events.
Thanks All!
Chris
Hi,
I am new to all of this. Any help you can provide would be greatly appreciated. I am currently working with Postman and I'm trying to get a list of all courses using the following call function:
GET /api/v1/courses
It is only pulling courses that are assigned to my account. I would like to get a list of all of the courses within the LMS. Can you tell me how I can call for a list of all courses?
Hello,
I use Perl and Canvas APIs to do all my SIS work. Here are some examples:
Create a course: /usr/bin/curl -s 'https://$DOMAIN.instructure.com/api/v1/accounts/$account_id/courses' -X POST -H '$AUTH_HEADER' -F 'course[name]=$course_name' -F 'course[course_code]=$course_code' -F 'course[sis_course_id]=$course_id' -F 'course[term_id]=$term_id'
Create the course section: /usr/bin/curl -s 'https://$DOMAIN.instructure.com/api/v1/courses/$canvas_course_id/sections' -X POST -H '$AUTH_HEADER' -F 'course_section[name]=$course_name' -F 'course_section[sis_section_id]=$section_id
Apply a template: /usr/bin/curl -s 'https://$DOMAIN.instructure.com/api/v1/courses/$canvas_course_id/content_migrations' -X POST -H '$AUTH_HEADER' -F 'migration_type=course_copy_importer' -F 'settings[source_course_id]=$template_number'
Enroll user: /usr/bin/curl -s 'https://$DOMAIN.instructure.com/api/v1/courses/$canvas_course_id/enrollments' -X POST -H '$AUTH_HEADER' -F 'enrollment[user_id]=$canvas_user_id' -F 'enrollment[type]=$role' -F 'enrollment[course_section_id]=$course_section_id' -F 'enrollment[enrollment_state]=active'
The enrollment and template calls are dependent on getting the the canvas_course_id and the canvas_section_id respectively. To do that, I stuff the json message returned from each call into a variable called $messages. From here I can located the "id" and store it in a variable. This is the code:
my $char = "id\":";
my $begin = index($messages,$char);
$begin+=4;
my $end = 10;
my $canvas_course_id = substr($messages,$begin,$end);
$canvas_course_id =~ s/\D+//g;
I do the same to get the canvas_section _id so I can enroll my users.
I'm looking for some sample Java code to interact with the Canvas API.
I teach math and Java at Tacoma Community College. I'm thinking of learning to use the API as a professional development goal, and also to overcome some limitations in the way the gradebook handles extra credit. I just learned of the existence of the API at a recent Washington State Canvas conference hosted here at TCC.
I've learned lots of languages and tools, dating back decades. I've always found the most effective jump-start is to find some working example code, and start tweaking with it. It looks like it would take months of reading to begin a Java project using the API "from scratch".
Can anyone point me to some simple Java code to access my Canvas courses? I'd expect to have to edit in things like the OAuth2 token, my college name, a course ID, etc. It looks like it shouldn't take too much code to do that, but two days of searching haven't yielded me any starting point.
I'd very much appreciate some sample code, or pointers to where else to ask.
Dave Straayer
In our previous LMS, we could query the log files to determine the number of times an individual link (URL, External tool, etc.) the a course was selected.
Is there a way to determine the number of time student / teachers click on a individual module item in a course?
I am trying to automate attaching files to an assignment using the API. I've successfully added comments to an assignment like this:
curl 'https://auburn.instructure.com/api/v1/courses/NNN/assignments/OOO/submissions/PPP' \
-X PUT \
-F 'comment[text_comment]=Good job.' \
-F 'submission[file_ids][]=72819643' \
-H "Authorization: Bearer "
However, when I try to upload a file like this:
-F 'comment[file_ids][]=72819643' \
it says
{"status":"unauthorized","errors":[{"message":"user not authorized to perform that action"}]}
I have carefully gone through the process of uploading the file and checking the file_id. It is correct.
FYI, if I do the following:
I don't get an error, but it doesn't upload the file as a submission.
Any suggestions would be appreciated!
Hi All,
Does anyone have any experience with creating and updating using the API without the use of a file.
I'm trying to write a c# program to update all courses with an sis_course_id field using a JSON string.
I can send data using the API and get a successful return code but the record will not update.
My code is below, any help would be greatly appreciated.
//Declare variablesstring canvasUrl = "https://XXXXXXXX.instructure.com/";string authToken = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";//Create HTTPClient link to CanvasConnection connection = new Connection();HttpClient client = connection.CreateHttpClient(canvasUrl, authToken);//Update course with id 200string jsonString = @{"sis_course_id"": ""123456""}";HttpContent httpContent = new StringContent(jsonString, Encoding.UTF8, "application/json");HttpResponseMessage response = await client.PutAsync("api/v1/courses/200", httpContent);
I would like to ask for a tiny addition to the enrollments end point (api/v1/courses/xxx/enrollments)
When getting list of enrollments for a course/course section, in the user section (highlighted below), the user email address is missing.
For us to get the user's email address, we need to make another call to the PROFILE end point.
Would it be possible to add user's primary email address to the user info so we save another call?
{"id":17452826,"user_id":3797794,"course_id":832406,"type":"StudentEnrollment","created_at":"2013-01-15T20:06:39Z","updated_at":"2016-04-11T13:38:19Z","associated_user_id":null,"start_at":null,"end_at":null,"course_section_id":889149,"root_account_id":97951,"limit_privileges_to_course_section":false,"enrollment_state":"active","role":"StudentEnrollment","role_id":2441,"last_activity_at":"2015-03-06T13:59:26Z","total_activity_time":5060,"sis_import_id":null,"grades":{"html_url":"https://evaluationkit.instructure.com/courses/832406/grades/3797794","current_score":null,"final_score":0,"current_grade":null,"final_grade":null},"sis_source_id":null,"sis_course_id":null,"course_integration_id":null,"sis_section_id":null,"section_integration_id":null,"html_url":"https://evaluationkit.instructure.com/courses/832406/users/3797794",
"user":{"id":3797794,"name":"Student 1","sortable_name":"1, Student","short_name":"Student 1","login_id":"student1@evaluationkit.com"}},
Matt.
How can I get user id from the access token?
I am new to Canvas API. I use PHP and curl to interact with the API. I am writing some code that can grade and comment assignment submissions using the Submission API. I have figured out how to PUT or POST single or multiple grades and comments. What I haven't figured out is how to modify an existing comment. Submitting a new grade will overwrite the existing one; however submitting a new comment will just add the new comment. The Submission API does not have a method to delete a comment or grade. Any help would be greatly appreciated.
Louie
For those few of us out there working with .NET, I have published a starter project implementing the API in C#.
It is meant as just that, a starter project, that can be easily modified.
I have created a workflow service to automate many admin tasks and reports associated with our instance of Canvas, and this starter project is essentially the base. Once you know how to make the calls using .NET, you can wrap the API calls in your business logic to meet your specific goals.
Hopefully this will be helpful.
I am new to the Canvas API offerings and this may not even be the correct forum, but here goes.
I have a use case where I need to capture an event in the Canvas web UI (instructor adding person to course) and have that event trigger an API external to Canvas. The Canvas APIs are great for events inbound to Canvas but I have not found a solution that would allow me to trigger events outbound. An LTI enabled tool provider seems like a possible solution but that would require the instructor to alter their workflow.
Are there any options to capture web UI events and have them trigger an external REST API?
Thanks for your consideration...
I need some help with grading group assignments. I am currently using the Submission API and the following request
POST /api/v1/courses/:course_id/assignments/:assignment_id/submissions/update_grades
to grade individual assignments and it has been working well. I was trying to use the same method to grade group assignments. For the parameters, I replaced the with the and I set "group_comment" to true. However, I have had no luck so far. I did not get any error, but grades and comments were not posted either. If you have any experience with grading group assignments, please share. Thank you.
Hello all,
Just sharing a bit of PHP code that can interact with the Canvas API without needing curl (if for whatever reason you don't have, or can't use the library).
The GET function includes logic that can deal with the Canvas API item return limit.
The POST function just requires a correctly formed array to post and you're good to go!
Make sure to set up a constant called TOKEN (this should be set to your current auth token). Or you could just edit the code and input it manually or with a variable/config file.
GitHub - MarcLightning/canvasUtils: A small set of scripts that interface with the Canvas REST API (or similar REST API)…
There is an error in the documentation for https://canvas.instructure.com/doc/api/peer_reviews.html
Peer Reviews - Canvas LMS REST API Documentation
as there are two sections entitled "Create Peer Review"
The second of these is about deleting a peer review.
It is unclear how one can use the API to assign a peer reviewer.
Question regarding to upload new file;
We are to upload some report file to user's File. I called Canvas uploadfile API passing the file parameters via guideline Uploading Files - Canvas LMS REST API Documentation . The file was uploaded correctly, but uploaded in the user's default File foder 'unfiled' instead of creating a new folder I defined in 'parent_folder_path' parameter passing in API call, It used to work correctly creating and uploading the file in a new folder specified in 'parent_folder_path'. Anyone has idea or experience using the uploadingfile api recently?
Thanks in advance,
Ruiling
On the test instance is there is limit to api call speed?
I am using the api to inactivate the section enrollments of students that have left a course. I am testing it in our test instance and initially the app would do a dozen or so api calls and the stop getting a response from canvas. I inserted a sleep of a couple seconds between calls and it to processed a lot more calls before doing the same thing. I am trying to figure out if this is an issue on my end, some limitation on the test instance or if it is a limitation on all instances.
Thanks
I am trying to get a email notification sent for an enrollment invitation and the email never gets sent. Sending a message to the same user via the ui widget works fine. Can anyone tell what I am missing? Appreciate your looking.
curl https://server.edu/api/v1/courses/sis_course_id:autoenrollmenttest1/enrollments \
-X POST \
-F 'enrollment[user_id]=sis_user_id:jpg_goog' \
-F 'enrollment[type]=ObserverEnrollment' \
-F 'enrollment[enrollment_state]=invited' \
-F 'enrollment[notify]=true' \
-H "Authorization: Bearer `cat ~/canvas/tokens/sis@canvas`"
The enrollment get created:
{
"associated_user_id": null,
"course_id": 133067,
"course_integration_id": null,
"course_section_id": 127851,
"created_at": "2017-01-11T00:02:23Z",
"end_at": null,
"enrollment_state": "creation_pending",
"html_url": "https://server.edu/courses/133067/users/123989",
"id": 687239,
"last_activity_at": null,
"limit_privileges_to_course_section": false,
"role": "ObserverEnrollment",
"role_id": 8,
"root_account_id": 1,
"section_integration_id": null,
"sis_account_id": null,
"sis_course_id": "autoenrollmenttest1",
"sis_import_id": null,
"sis_section_id": null,
"sis_user_id": "jpg_goog",
"start_at": null,
"total_activity_time": 0,
"type": "ObserverEnrollment",
"updated_at": "2017-01-11T00:02:23Z",
"user_id": 123989
}
I made a simple python program to get information about both users and students in a course with the output formatted as a spreadsheet (.xlsx). One of the features of this program was to get the various communication channels associated with each person. Adding and removing Twitter as a registered service revealed that there is a need for a third value ('inactive') for the "workflow state" associated with a communication channel. For details can code see List of users and students in a course: Chip sandbox
Note that the program could be split into a list users program and a list students program, but this example of using the API was relatively simple and illustrates the power of the API.
When I try to get a list of my courses using the get URL: ...api/v2/courses I get only 10 of my courses.
I have read the documentation for this call a dozen times and cannot spot where it hints that this is the expected behavior for this call.
I see this with browsers but also when I try to use VBA coding. It is a problem because the most important courses for me are not in the returned list.
I have many more courses on the books (the Canvas GUI lists 26 which are currently relevant).
What do I have to do to get ALL my courses for the current quarter.
What would the URL look like to get all the current and future courses where I have at least one student enrolled?
EDITING to Add: I posted the above without realizing that there were already 8 pages in this thread. (I am relatively new to Canvas and very new to this Forum)
On one of the earlier pages in this thread I learned that pagination is used for some calls It appears that the documentation is failing to identify that paging is needed for this. Perhaps this could be added.
If I run into other API calls were paging is needed, how do I know this is happening. In other words, how do I know that when I make the call as documented, that the returned data is paginated? I have been making API calls and staring at JSON responses all day (with VBA in Excel) and noticed nothing that would give me a hint to this. I did now find the documentation on Pagination but do not understand it; what and where is the Link header? I do see a vague hint on that page that I could pass the a parameter to force the page size to some "unspecified number". What is the syntax for that?
Hello:
I hope I am posting this question in the right place...
In the fall of 2015 I was trying to develop my own speedgrader for open response quiz questions when I discovered that the quiz API was not working as documented. This long process is covered in this thread that included Deactivated user, @James and some key help from wfrakes.
In the end Jason Sparks said:
This is a very innovative use of the API. The current API remains in a beta stage as we are actively considering some new development on the quizzes front. For now there will not be any further development of the current API. We will share more in the near future as things progress.
17 months later I thought I would check back and see if any progress has been made. However, the documentation does NOT seem to have been updated - so the broken API calls and misleading examples (see my explanation) are still there.
Nevertheless, hope springs eternal and I wanted to see if someone from Instructure could provide an update.
Fingers crossed,
Sam Dickerman
Brookline High School
Hello Everyone,
Building my first API - trying to pull the current user's first and last name for a printable certificate.
When I put the following url in a browser, it returns what I am looking for.
https://msmu.instructure.com/api/v1/users/self/profile
The above does not require my access token when used in the browser's address bar. But when I try and use PHP cURL it asks me to authenticate to pull that same URL. When I try and use our access token - it does not return the current user logged in, but rather my API user profile.
How do I use PHP cURL to get the current user's profile credential without authenticating?
Scoured the online documentation and sample scripts from Google without any luck. Thanks in advance for pointing me in the right direction.
Cheers,Mitch Gohman
Hey, as a part of a product requirement I need to add a link in each Canvas course to a predefined URL. In order to do so, I'm using the `external_tools` API in order to create them. I pass different values in the course_navigation param and a button is created at the bottom of the left navbar in the course navigation page. I'd like to place this button at the beginning of this navbar or, if it not possible, create the button in the left navbar of the course navigation (I've tried using the course_home_sub_navigation param but It didn't work). Any ideas? Thanks. Here is the doc I've been reading: External Tools - Canvas LMS REST API Documentation
Hello Everyone! I'm very new to APIs as well but I was wondering if It was possible to transfer grades from one course to another using an API? If so any tips on how to approach this?
The create assignment API
seems to create two duplicate assignments (instead of one) every time I call it. Has anyone else experienced this?
(with root-privileges)
`/api/v1/courses/sis_course_id:?include[]=sections`
always returns the course (just fine) with:
`..., sections: [], ...`
(empty array...), where I would expect to get at least elementary information on a course's sections (sis-integrated and non-sis-integrated).
What am I doing wrong, or is this a bug?
Hi there, I am new to Canvas and I'd like to use it for my organization. Before that I really need to know if there is a way for my developers to interact with Canvas' video player API (i.e. Will I be able to prevent my students to see the following video without having finished the previous? Will I be able to embed a script to launch a random pop-up that asks a student if he is still watching the video to test his attention?). To sum up I would like to know what is the level of personalization of your platform (of course I'd like to suscribe to the full account and not only to the free one). Please let me know Best, Emanuela
It's been awhile since I had an API question I wasn't able to figure out and forgot this thread existed so I posted a question about setting to do dates on assignment pages using the API that I will post here as well in case anyone has any insights.
Last Fall Canvas added the ability to set a date on pages so that they appear in the student to do list:
Unfortunately, there is no information about this functionality available in the Pages API.
I can view that date using the List pages or Show page API
I have tried the typical Update/create page api pattern for updating page information by passing wiki_page[todo_date] as a date similar to what I would do to update an assignment date, but that doesn't appear to do anything.
Anyone worked with this yet, or any of the awesome Canvas Engineers have any information on how to set this date through the API?
Thanks fo any insights!
Hi there!
I am fighting with the api trying to create "calculated_question" quizzes avoiding the Canvas web interface. I.e. my goal is to have a script populate/modify the table of variable values and results.
First I used the Python canvasapi library and was able to create a calculated_question and populate the table of pre-calculated values, but the answer-field is always reset to 0.0 and also the field for the formula is not populated. I then tried to modify an existing calculated_question using canvasapi and was not at all able to get any result.
I expected this to be a problem in the canvasapi module, so I used postman to send the data directly to the api. Creating a new calculated_question here is even more frustrating since only a "text_only_question" is created from the json object. Trying to modify the question afterwards with a second POST-call only results in an "422 Unprocessable Entity" error.
Some MWEs:
a) working example creating a new calculated_question using canvasapi in python. However, neither the 'answer' values nor the 'formula' field is accepted
new_question = { 'question_name': "Q4", 'question_type': 'calculated_question', 'question_text': '
[a]*[b]=?
question = quiz.create_question(question=new_question)
-> resulting json structure
{ "id": 63460352, "quiz_id": 3793795, "quiz_group_id": null, "assessment_question_id": 100291102, "position": null, "question_name": "Q4", "question_type": "calculated_question", "question_text": "
b) POSTMAN json structure which will only result in a new "text_only_question" when send to the /api/v1/courses/:course_id/quizzes/:quiz_id/questions endpoint
{"quiz_group_id":null,"position":null,"question_name":"Q6","question_type":"calculated_question","question_text":"\u003cp\u003e[a]*[b]=?\u003c/p \u003e","points_possible":1.0,"correct_comments":"","incorrect_comments":"","neutral_comments":"","correct_comments_html":"","incorrect_comments_html":"","neutral_comments_html":"","answers":[{"weight":100,"variables":[{"name":"a","value":"8"},{"name":"b","value":"4"}],"answer":64},{"weight":100,"variables":[{"name":"a","value":"4"},{"name":"b","value":"4"}],"answer":42}],"variables":[{"name":"a","min":1.0,"max":10.0,"scale":0},{"name":"b","min":1.0,"max":10.0,"scale":0}],"formulas":[{"formula":"a+b"}],"answer_tolerance":"5%","formula_decimal_places":1,"matches":null,"matching_answer_incorrect_matches":null}
if the same structure is sent to the endpoint of an already existing question, a 422-error is created.
Am I missing something or is it simply impossible to create a calculated_question through the api - if so, why? I could not find any comment or any example anywhere...
Canvas Data Services sent out an alert that a course was concluded (because the course was concluded) and the status of each user in the UI is set to complete, however, the enrollments API endpoint shows the status of each user in the course as active. Is this a common issue? Have I misinterpreted how the individual…
How can one track Canvas Media use without having the reports available from Canvas Studio? Checking API endpoints and the Data 2 schema, there do not seem to be dedicated Canvas Media endpoints. Am I missing some? A method I've considered is using the body field of the wiki_pages table, as this contains the html code of…
Hello, I'm trying to utilize an API call to pull completed certificates and was hoping to download and store the certs as a backup. I can successfully run the API call but it will not allow me to view the certificate unless I access the URL while signed into an account where it's "my" cert. Is there a permissions setting…
UI for weekly progression idea that rest in the Schedule tab of the **K-12 UI** of Canvas it's incomplete and I really would not take it and push it into instance but I am going to post it here because in the past people like @James && @robotcars || @Steve_25 have had terrific input in the past... maybe w/their eyes and…
I have a new React + Flask webapp. It has its own login for users to start using the app. I have added this as an external tool in Canvas. What I want initially is to see of canvas users can start using the webapp without having to login if they click on the external tool link in a canvas course. I have 2 methods…