yoonjj
Community Member

Accessing external server from within canvas

I am trying to build an application that sends an http request to an external server and processes the returned JSON within canvas whenever a student submits an assignment. 

I found a lot of resources on accessing the Instructure API from external calls, but I need to do the opposite -- here canvas is the client and the external endpoint is the server. 

Could you link me to some resources on how I can implement this?

0 Kudos
3 Replies
themidiman
Community Champion

Sounds like this would be a case for using your Canvas Theme JS overrides file. You would need to set up a proper event handler to detect when the assignment was submitted and then execute a XHR request against your server's endpoint.

0 Kudos
matthew_buckett
Community Contributor

If you want an external server to do something when an assignment in submitted in Canvas you can subscribe the Live Events that Canvas publishes: https://community.canvaslms.com/t5/Admin-Guide/How-do-I-subscribe-to-Live-Events-using-Canvas-Data-S...

You should be able to configure and endpoint that Canvas will send a message to when someone submits an assignment, in the JSON you will get details of the assignment and who is submitting, the documentation for the JSON message that is sent for student assignment submissions is:

https://canvas.instructure.com/doc/api/file.data_service_canvas_submission.html

If you then need to get more data you can use the Canvas APIs to lookup further information.

 

0 Kudos

You may need to reach out to your CSM to get the live events support enabled. The feature is called "Data Services".

Then, in the docs, you'll find an event called "submission_created": https://collegiseducation.instructure.com/doc/api/file.data_service_canvas_submission.html#submissio...

 

0 Kudos