The Instructure Community will enter a read-only state on November 22, 2025 as we prepare to migrate to our new Community platform in early December.
Read our blog post for more info about this change.
Found this content helpful? Log in or sign up to leave a like!
We would like to push our academic calendar from our website's iCalendar file into canvas using the API. I've been successful in getting events and deleting events using the API, but I'm running into issues when trying to create new events. I'm using a PowerShell script to automate the process. My request to create an event is formed as follows:
Invoke-RestMethod -Uri https://milligan.instructure.com/api/v1/calendar_events.json -Method POST -H $headers -Body $json
My headers are OK since they're the same as I've used for getting and deleting calendar events. It seems there is something wrong with the URL.
Here is my JSON object (the $json variable):
{
"calendar_event[start_at]": "2016-07-19T21:00:00Z",
"calendar_event[title]": "Test Event",
"calendar_event[end_at]": "2016-07-19T22:00:00Z",
"calendar_event[context_code]": "course_348"
}
I receive the following error when making this request:
{"errors":[{"message":"The specified resource does not exist."}],"error_report_id":492649}
Anybody have any success using the API for creating calendar events? If so, how were your requests formatted? I thought I was matching what was in the API documentation but could be missing something. Any ideas what I might have wrong? Thanks for any help.
David
Solved! Go to Solution.
Answered in Google Groups
<hr>
Graham - thanks for that info! That seems to have done it! I thought I had tried that, but I think I was leaving off the calendar_event[] part of each field parameter.
For reference, here's my request URL:
Hi David,According to the API docs for Calendar Events, that endpoint is expecting form-encoded data, not JSON:
curl 'https://<canvas>/api/v1/calendar_events.json' \ -X POST \ -F 'calendar_event[context_code]=course_123' \ -F 'calendar_event[title]=Paintball Fight!' \ -F 'calendar_event[start_at]=2012-07-19T21:00:00Z' \ -F 'calendar_event[end_at]=2012-07-19T22:00:00Z' \ -H "Authorization: Bearer <token>"Try sending the data as form-encoded data in the POST body and see what happens.
Answered in Google Groups
<hr>
Graham - thanks for that info! That seems to have done it! I thought I had tried that, but I think I was leaving off the calendar_event[] part of each field parameter.
For reference, here's my request URL:
Hi David,According to the API docs for Calendar Events, that endpoint is expecting form-encoded data, not JSON:
curl 'https://<canvas>/api/v1/calendar_events.json' \ -X POST \ -F 'calendar_event[context_code]=course_123' \ -F 'calendar_event[title]=Paintball Fight!' \ -F 'calendar_event[start_at]=2012-07-19T21:00:00Z' \ -F 'calendar_event[end_at]=2012-07-19T22:00:00Z' \ -H "Authorization: Bearer <token>"Try sending the data as form-encoded data in the POST body and see what happens.
Hi
I finally found the correct JSON format for creating/editing a calendar event :
{
"calendar_event":
{
"context_code": "group_2919",
"title": "Party",
"description": "Shindig",
"start_at": "2019-03-04T12:00:00Z",
"end_at": "2019-03-04T13:00:00Z",
"location_name": "Martin's House",
"all_day": "false"
}
}
This adds the event to the pre-existing group with ID = 2919.
I've managed to sync our teaching sessions (lectures, seminars, workshops...) from our SRS into Canvas via the API. Students have membership of groups via SIS Import of group_categories.csv, groups.csv and groups_membership.csv. The group id can be retrieved using the Groups API.
What I didn't realise is that students in groups can edit/delete the group calendar events I've created via their calendar, which is not what we want!
Martin
Community helpTo interact with Panda Bot, our automated chatbot, you need to sign up or log in:
Sign inTo interact with Panda Bot, our automated chatbot, you need to sign up or log in:
Sign in