Hey guys, I'm working on a project with a friend for fun and we are unable to get calendars to be returned. Am i entering the url incorrectly?
Yes, you are entering it incorrectly when you specify both types, but that's not the reason why you're not getting anything.
If you look at the API documentation for the list calendar events, there is an easy to miss note. I wasn't able to get anything until I read it.
List of context codes of courses/groups/users whose events you want to see. If not specified, defaults to the current user (i.e personal calendar, no course/group events). Limited to 10 context codes, additional ones are ignored. The format of this field is the context type, followed by an underscore, followed by the context id. For example: course_42
If you don't add a context_codes to the query, you just get the personal calendar, which for most people is blank.
These don't return anything for me
These do return results
There are two that look very similar (just the order of type=assignment and type=event) are switched. The type parameter is does not allow multiple entries and it will take whichever one comes last. So, specifying event then assignment is really only specifying assignment and putting assignment followed by event is really just specifying event.
I also couldn't get it to show me any events, even those on my personal calendar, unless I put in all_events=1. But all_events doesn't mean just events, when I include that with type=assignments, it includes all assignments within a context.
If I try to include type=assignment without a context_code, I don't get anything.
Hope that helps.
There seem to be some restrictions on accessing calendar data via the API. I can only get first 10 events/assignments from a calendar.
This is the command I'm using:
Any ideas on why this would be happening or how to work around it?
Thanks in advance for any help.
That sounds like a pagination issue that is in almost every API call.
The quick fix is add a query_parameter per_page=100
But there are times when you'll have more than 100, so the real fix is to handle pagination. You can read about it in Pagination - Canvas LMS REST API Documentation
Thank you! That was my problem. I'm relatively new to working with API's and pagination had never occurred to me.
Retrieving data ...